<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>血染钟楼JSON文件生成工具by黑心恰克</title>
    <style>
        :root {
            /* 现代化配色方案 */
            --primary-color: #8d0000;
            --secondary-color: #6d0000;
            --accent-color: #ff6b6b;
            --background-color: #1a1a1a;
            --surface-color: #2d2d2d;
            --card-bg-color: #ffffff;
            --text-color: #333333;
            --text-light: #666666;
            --border-color: #e0e0e0;
            --header-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --header-text-color: #ffffff;
            --hover-color: #f8f9fa;
            --shadow-light: 0 2px 8px rgba(0,0,0,0.1);
            --shadow-medium: 0 4px 16px rgba(0,0,0,0.15);
            --shadow-heavy: 0 8px 24px rgba(0,0,0,0.2);
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            color: var(--text-color);
            line-height: 1.6;
        }

        /* 头部样式 */
        .header {
            background: var(--header-bg);
            color: var(--header-text-color);
            padding: 24px 16px;
            text-align: center;
            box-shadow: var(--shadow-medium);
            position: sticky;
            top: 0;
            z-index: 100;
            backdrop-filter: blur(10px);
        }

        .header h1 {
            margin: 0;
            font-size: clamp(1.5rem, 4vw, 2.5rem);
            font-weight: 700;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
            margin-bottom: 8px;
        }

        .header h4 {
            color: rgba(255, 255, 255, 0.9);
            margin: 0;
            font-size: clamp(0.9rem, 2.5vw, 1.1rem);
            font-weight: 400;
        }

        .header h4.right-aligned {
            text-align: center;
            margin: 8px 0 0;
        }

        /* 主体容器样式 */
        .container {
            max-width: 100%;
            margin: 0;
            padding: 16px;
            min-height: calc(100vh - 120px);
        }

        @media (min-width: 768px) {
            .container {
                max-width: 1200px;
                margin: 0 auto;
                padding: 24px;
            }
        }

        .script-selection {
            margin: 20px 0;
            padding: 20px;
            background: var(--card-bg-color);
            border-radius: 16px;
            box-shadow: var(--shadow-light);
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 12px;
            transition: all 0.3s ease;
            border: 1px solid var(--border-color);
        }

        .script-selection:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-medium);
        }

        .script-selection label {
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            border-radius: 8px;
            transition: all 0.3s ease;
            font-weight: 500;
            font-size: 14px;
        }

        .script-selection label:hover {
            background: var(--hover-color);
            color: var(--primary-color);
        }

        .script-selection input[type="checkbox"] {
            width: 18px;
            height: 18px;
            accent-color: var(--primary-color);
        }

        @media (max-width: 768px) {
            .script-selection {
                grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
                gap: 8px;
                padding: 16px;
            }
            
            .script-selection label {
                font-size: 13px;
                padding: 6px 8px;
            }
        }

        .search-container {
            position: relative;
            margin-bottom: 20px;
        }

        #search-role-input {
            width: 100%;
            padding: 16px 20px;
            border: 2px solid var(--border-color);
            border-radius: 12px;
            font-size: 16px;
            background: var(--card-bg-color);
            transition: all 0.3s ease;
            box-shadow: var(--shadow-light);
        }

        #search-role-input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(141, 0, 0, 0.1);
            transform: translateY(-1px);
        }

        #search-role-input::placeholder {
            color: var(--text-light);
        }

        #search-results {
            position: absolute;
            background: var(--card-bg-color);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            max-height: 300px;
            overflow-y: auto;
            z-index: 100;
            width: 100%;
            top: 100%;
            margin-top: 4px;
            box-shadow: var(--shadow-medium);
        }

        .role-list {
            background: var(--card-bg-color);
            border-radius: 16px;
            padding: 24px;
            margin-bottom: 20px;
            box-shadow: var(--shadow-light);
            transition: all 0.3s ease;
            border: 1px solid var(--border-color);
        }

        .role-list:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-medium);
        }

        .role-list h2 {
            font-size: 1.5rem;
            font-weight: 700;
            margin-bottom: 20px;
            padding-bottom: 12px;
            border-bottom: 2px solid var(--border-color);
        }

        .role-columns {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
        }

        .role-column {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .role-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 16px;
            border-radius: 12px;
            transition: all 0.3s ease;
            border: 1px solid transparent;
            background: rgba(0, 0, 0, 0.02);
        }

        .role-item:hover {
            transform: translateX(4px);
            background: var(--hover-color);
            border-color: var(--border-color);
            box-shadow: var(--shadow-light);
        }

        .role-item label {
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            font-weight: 500;
            font-size: 14px;
            line-height: 1.4;
        }

        .role-item input[type="checkbox"] {
            width: 18px;
            height: 18px;
            accent-color: var(--primary-color);
        }

        @media (max-width: 768px) {
            .role-columns {
                grid-template-columns: 1fr;
                gap: 12px;
            }
            
            .role-item {
                padding: 10px 12px;
            }
            
            .role-item label {
                font-size: 13px;
            }
        }

        .role-item-img {
            max-width: 50px;
            max-height: 50px;
            border-radius: 4px;
        }

        button {
            padding: 14px 28px;
            font-size: 16px;
            font-weight: 600;
            margin: 8px 4px;
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            color: white;
            border: none;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: var(--shadow-light);
            position: relative;
            overflow: hidden;
        }

        button:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-medium);
            background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
        }

        button:active {
            transform: translateY(0);
            box-shadow: var(--shadow-light);
        }

        button:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }

        @media (max-width: 768px) {
            button {
                padding: 12px 20px;
                font-size: 15px;
                width: 100%;
                margin: 6px 0;
            }
        }

        .button-group {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            justify-content: center;
            margin: 24px 0;
        }

        @media (max-width: 768px) {
            .button-group {
                flex-direction: column;
                gap: 8px;
            }
        }

        .selection-info {
            margin: 24px 0;
            padding: 20px;
            background: var(--card-bg-color);
            border-radius: 16px;
            box-shadow: var(--shadow-light);
            border: 1px solid var(--border-color);
            transition: all 0.3s ease;
            font-size: 15px;
            line-height: 1.6;
        }

        .selection-info:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-medium);
        }

        a {
            color: var(--primary-color);
            text-decoration: none;
            transition: color 0.3s ease, transform 0.2s ease;
            display: block;
            text-align: center;
            margin-bottom: 20px;
        }

        a:hover {
            color: var(--secondary-color);
            transform: translateY(-2px);
        }

        .image-preview {
            position: fixed;
            top: -9999px;
            left: -9999px;
        }

        .role-card {
            background: white;
            padding: 20px;
            margin: 10px;
            border: 1px solid var(--border-color);
            max-width: 600px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .role-item.hidden {
            display: none;
        }

        /* 统一按钮基础样式 */
        button, 
        .dir-button,
        .save-dir-button, 
        .cancel-dir-button,
        .violet-button {
            padding: 12px 24px;
            font-size: 16px;
            border: none;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            margin-top: 20px;
        }

        /* 按钮悬停效果 */
        button:hover, 
        .dir-button:hover,
        .save-dir-button:hover, 
        .cancel-dir-button:hover,
        .violet-button:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
        }

        /* 按钮点击效果 */
        button:active, 
        .dir-button:active,
        .save-dir-button:active, 
        .cancel-dir-button:active,
        .violet-button:active {
            transform: translateY(-1px);
            box-shadow: 0 3px 4px rgba(0, 0, 0, 0.1);
        }

        /* 保留原有按钮颜色 */
        button {
            background-color: var(--primary-color);
            color: white;
        }

        .dir-button {
            background-color: #6b6b87;
            color: white;
        }

        .dir-button:hover {
            background-color: #5a5a75; 
            transform: translateY(-3px);
            box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
        }


        /* 搜索结果容器样式 */
        #search-results {
            position: absolute;
            background-color: white;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            max-height: 200px;
            overflow-y: auto;
            z-index: 1000;
        }

        /* 搜索结果项样式 */
        #search-results div {
            padding: 8px 12px;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        /* 鼠标悬停时的样式 */
        #search-results div:hover {
            background-color: #f0f0f0;
        }

        /* 新增颜色样式 */
        .role-list h2 {
            font-size: 1.5em;
        }

        .role-list h2 {
        font-size: 1.5em;
    }
        
    
    /* 镇民标题样式 */
        #townsfolk-list h2 {
            color: #00008B; /* 深蓝色 */
        }
        /* 外来者标题样式 */
        #outsiders-list h2 {
            color: #0000FF; /* 蓝色 */
        }
        /* 爪牙标题样式 */
        #minions-list h2 {
            color: #FF6666; /* 浅红色 */
        }
        /* 恶魔标题样式 */
        #demons-list h2 {
            color: #FF0000; /* 鲜红色 */
        }

        /* 新增类样式，用于调整 h4 位置 */
        .header h4.right-aligned {
            text-align: right;
            margin-right: 20px; /* 可根据需要调整右边距 */
        }


        /* dirArea 样式调整 */
        .dirArea {
            width: 100%;
            background: var(--card-bg-color);
            border-radius: 16px;
            padding: 24px;
            margin: 24px 0;
            box-shadow: var(--shadow-light);
            border: 1px solid var(--border-color);
            transition: all 0.3s ease;
        }

        .dirArea:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-medium);
        }

        .dirArea h2 {
            color: #ff9500;
            margin-bottom: 16px;
            font-size: 1.4rem;
            font-weight: 700;
        }

        .dirArea h3 {
            color: #ff6b35;
            margin-bottom: 20px;
            font-size: 1rem;
            font-weight: 600;
        }

        #dir-input-group {
            background: #f8f9ff;
            border-radius: 12px;
            padding: 24px;
            margin-top: 16px;
            border: 2px solid #e3e8ff;
        }

        #dir-input-group div {
            margin-bottom: 20px;
        }

        #dir-input-group h4 {
            margin-bottom: 8px;
            font-weight: 600;
            color: var(--text-color);
            font-size: 14px;
        }

        #dir-input-group input,
        #dir-input-group textarea,
        #dir-input-group select {
            width: 100%;
            padding: 12px 16px;
            border: 2px solid var(--border-color);
            border-radius: 8px;
            font-size: 14px;
            background: var(--card-bg-color);
            transition: all 0.3s ease;
        }

        #dir-input-group input:focus,
        #dir-input-group textarea:focus,
        #dir-input-group select:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(141, 0, 0, 0.1);
        }

        #dir-input-group textarea {
            min-height: 100px;
            resize: vertical;
        }

        .input-row {
            display: flex;
            gap: 12px;
            align-items: flex-end;
        }

        .input-row input {
            flex: 1;
        }

        .input-row span {
            font-size: 14px;
            color: var(--text-light);
        }

        @media (max-width: 768px) {
            .input-row {
                flex-direction: column;
                gap: 8px;
                align-items: stretch;
            }
        }



        .button-group {
            width: 100%; /* 宽度撑满父容器 */
            display: flex;
            gap: 10px;
            justify-content: center;
            margin-top: 20px;
        }




        /* Toggle Switch 样式 */
        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 60px;
            height: 34px;
            margin-left: 10px;
        }
        
        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        
        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: .4s;
            border-radius: 34px;
        }
        
        .slider:before {
            position: absolute;
            content: "";
            height: 26px;
            width: 26px;
            left: 4px;
            bottom: 4px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }
        
        input:checked + .slider {
            background-color: #4d0579;
        }
        
        input:checked + .slider:before {
            transform: translateX(26px);
        }
        
        .toggle-label-off,
        .toggle-label-on {
            position: absolute;
            line-height: 34px;
            color: white;
            font-size: 14px;
        }
        
        .toggle-label-off {
            left: 15px;
            display: block;
        }
        
        .toggle-label-on {
            right: 15px;
            display: none;
        }
        
        input:checked ~ .toggle-label-off {
            display: none;
        }
        
        input:checked ~ .toggle-label-on {
            display: block;
        }

        /* 生成区域样式 */
        .generate-section {
            background: var(--card-bg-color);
            border-radius: 16px;
            padding: 24px;
            margin: 24px 0;
            box-shadow: var(--shadow-light);
            border: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            gap: 16px;
            align-items: center;
        }

        .file-name-input input {
            width: 100%;
            max-width: 400px;
            padding: 16px 20px;
            border: 2px solid var(--border-color);
            border-radius: 12px;
            font-size: 16px;
            background: var(--card-bg-color);
            transition: all 0.3s ease;
            text-align: center;
        }

        .file-name-input input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(141, 0, 0, 0.1);
            transform: translateY(-1px);
        }

        .generate-button {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
            font-size: 18px;
            padding: 16px 32px;
            border-radius: 16px;
            box-shadow: var(--shadow-medium);
            min-width: 200px;
        }

        .generate-button:hover {
            background: linear-gradient(135deg, #20c997 0%, #28a745 100%);
            transform: translateY(-3px);
            box-shadow: var(--shadow-heavy);
        }

        @media (max-width: 768px) {
            .generate-section {
                padding: 20px;
            }
            
            .file-name-input input {
                max-width: 100%;
            }
            
            .generate-button {
                width: 100%;
                min-width: auto;
            }
        }

        /* 搜索结果项样式优化 */
        #search-results div {
            padding: 12px 16px;
            cursor: pointer;
            transition: all 0.2s;
            border-radius: 8px;
            margin: 4px 8px;
            font-weight: 500;
        }

        #search-results div:hover {
            background: var(--hover-color);
            color: var(--primary-color);
        }

        /* 链接样式优化 */
        a {
            display: block;
            text-align: center;
            margin: 20px 0;
            color: white;
            background: rgba(255, 255, 255, 0.1);
            padding: 12px 20px;
            border-radius: 12px;
            text-decoration: none;
            font-weight: 600;
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
        }

        a:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: translateY(-2px);
        }

    </style>
</head>




<body>
    <div class="header">
        <h1>血染钟楼JSON文件</h1>    
        <h1>生成工具</h1>
        
        <h4 class="right-aligned">by 1萌萌</h4>
    </div>
    <div class="container">
        <div class="script-selection">
            <label><input type="checkbox" name="script" value="暗流涌动" checked> 暗流涌动</label>
            <label><input type="checkbox" name="script" value="黯月初升" checked> 黯月初升</label>
            <label><input type="checkbox" name="script" value="梦殒春宵" checked> 梦殒春宵</label>
            <label><input type="checkbox" name="script" value="实验性角色" checked> 实验性角色</label>
            <label><input type="checkbox" name="script" value="华灯初上" checked> 华灯初上</label>
            <label><input type="checkbox" name="script" value="山雨欲来" checked> 山雨欲来</label>
            <label><input type="checkbox" name="script" value="旧版角色" checked> 旧版角色</label>
        </div>

        <div class="search-container">
            <input type="text" id="search-role-input" placeholder="🔍 中文名、拼音首字母搜角色...">
            <div id="search-results"></div>
        </div>

        <details class="role-list" id="townsfolk-list" open>
            <summary><h2 style="display:inline">镇民</h2></summary>
            <div class="role-columns" id="townsfolk-columns">
                <!-- 角色复选框动态加载 -->
            </div>
        </details>
        <details class="role-list" id="outsiders-list" open>
            <summary><h2 style="display:inline">外来者</h2></summary>
            <div class="role-columns" id="outsiders-columns">
                <!-- 角色复选框动态加载 -->
            </div>
        </details>
        <details class="role-list" id="minions-list" open>
            <summary><h2 style="display:inline">爪牙</h2></summary>
            <div class="role-columns" id="minions-columns">
                <!-- 角色复选框动态加载 -->
            </div>
        </details>
        <details class="role-list" id="demons-list" open>
            <summary><h2 style="display:inline">恶魔</h2></summary>
            <div class="role-columns" id="demons-columns">
                <!-- 角色复选框动态加载 -->
            </div>
        </details>
        <details class="role-list" id="travelers-list" open>
            <summary><h2 style="display:inline">旅行者</h2></summary>
            <div class="role-columns" id="travelers-columns">
                <!-- 角色复选框动态加载 -->
            </div>
        </details>
        <details class="role-list" id="fabled-list" open>
            <summary><h2 style="display:inline">传奇</h2></summary>
            <div class="role-columns" id="fabled-columns">
                <!-- 角色复选框动态加载 -->
            </div>
        </details>
    
        <!-- 显示自定义角色输入区域-->
        <div class="dirArea">
            <h2 style="color: #ffc107; margin-bottom: 15px;">自定义角色</h2>
            <h3 style="color: #F0CA00; margin-bottom: 15px;">没有自定义角色（非官方角色）不要点！！！</h3>

            <div style="display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 20px 0;">
                <button class="dir-button" onclick="toggleDirInput()">添加自定义角色</button>
        </div>
            <div id="dir-input-group" style="display: none; margin-top: 10px; background-color: #b1b1da;">
                <div>
                    <h4>角色中文名（必填*）：</h4>
                    <input type="text" id="dir-role-name" placeholder="自定义角色中文名">
                </div>
                <div>
                    <h4>角色能力描述（必填*）：</h4>
                    <textarea id="ability" placeholder="自定义角色能力描述"></textarea>
                </div>
                <div>
                    <h4>角色类型（必填*）：</h4>
                    <select id="sch_team">
                        <option value="镇民">镇民</option>
                        <option value="外来者">外来者</option>
                        <option value="爪牙">爪牙</option>
                        <option value="恶魔">恶魔</option>
                        <option value="旅行者">旅行者</option>
                    </select>
                </div>
                <div>
                    <h4>首夜行动顺序（选填）：</h4>
                    <div class="input-row">
                        <input type="number" id="firstNight" placeholder="正整数" style="width: 120px;" onkeydown="return event.keyCode !== 38 && event.keyCode !== 40">
                        <span>参考值:</span>
                        <select id="firstNightRef" style="flex: 1;">
                            <option value="">点此查看官方角色首页行动顺序</option>
                        </select>
                    </div>
                </div>
                <div>
                    <h4>其他夜晚行动顺序（选填）：</h4>
                    <div class="input-row">
                        <input type="number" id="otherNight" placeholder="正整数" style="width: 120px;" onkeydown="return event.keyCode !== 38 && event.keyCode !== 40">
                        <span>参考值:</span>
                        <select id="otherNightRef" style="flex: 1;">
                            <option value="">点此查看官方角色其他夜晚行动顺序</option>
                        </select>
                    </div>
                </div>
                <div>
                    <h4>首夜提示信息（选填）：</h4>
                    <textarea id="firstNightReminder" placeholder="首夜提示信息"></textarea>
                </div>
                <div>
                    <h4>其他夜晚提示信息（选填）：</h4>
                    <textarea id="otherNightReminder" placeholder="其他夜晚提示信息"></textarea>
                </div>
                <div>
                    <h4>角色提示token（选填）：</h4>
                    <div class="input-row">
                        <input type="text" id="reminders1" placeholder="token1">
                        <input type="text" id="reminders2" placeholder="token2">
                        <input type="text" id="reminders3" placeholder="token3">
                    </div>
                </div>
                <div>
                    <h4>全局提示token（选填）：</h4>
                    <div class="input-row">
                        <input type="text" id="remindersGlobal1" placeholder="token1">
                        <input type="text" id="remindersGlobal2" placeholder="token2">
                        <input type="text" id="remindersGlobal3" placeholder="token3">
                    </div>
                </div>
                <div>
                    
                    
                        <h4>角色有设置调整能力（选填）：</h4>
                        <label class="toggle-switch">
                            <input type="checkbox" name="setup" value="1">
                            <span class="slider"></span>
                        </label>
                    
                </div>
                <div>
                    <h4>角色图标网址（选填）：</h4>
                    <input type="text" id="image" placeholder="自定义角色使用的图片URL">
                </div>
            <!-- 移动按钮到 dirArea 底端 -->
            <button class="cancel-dir-button" onclick="toggleDirInput()">取消</button>
            <button class="save-dir-button" onclick="addDirRole()">保存</button>            
            
            </div>
        </div>


        <!-- 显示选择数量的区域 -->
        <div class="selection-info" id="selection-info">
            已选择：镇民 0 个，外来者 0 个，爪牙 0 个，恶魔 0 个。
            注意：其中包含旧版角色0个。
        </div>

        <!-- 已选择角色预览区域 -->
        <div id="selected-preview" style="background: var(--card-bg-color); border:1px solid var(--border-color); border-radius:16px; padding:16px; margin-top:12px; box-shadow: var(--shadow-light)">
            <div style="display:flex;justify-content:space-between;align-items:center; margin-bottom:8px">
                <h3 style="font-size:16px;margin:0">已选择角色预览</h3>
                <div>
                    <button class="violet-button" onclick="toggleDirInput()">+ 添加自定义角色</button>
                    <button class="violet-button" onclick="clearAllSelections()">清空</button>
                </div>
            </div>
            <div id="selected-preview-content" style="display:flex;flex-direction:column;gap:12px"></div>
        </div>
        
        <!-- 新增超链接 -->
        <a href="https://clocktower-wiki.gstonegames.com/index.php?title=%E8%A7%84%E5%88%99%E8%B0%83%E6%95%B4%E6%8F%90%E5%89%8D%E5%85%AC%E7%A4%BA" target="_blank" style="font-size: calc(100% + 4px); font-weight: bold;text-align: left;"">新、旧角色能力对比</a>
        


        <div class="meta-section" style="background:#fff;border:1px solid var(--border-color);border-radius:16px;padding:16px;margin:16px 0;box-shadow: var(--shadow-light)">
            <h3 style="margin-bottom:12px;font-size:16px">剧本元信息（导出 JSON 将包含一个 _meta 对象）</h3>
            <div class="input-row" style="display:flex;gap:12px;flex-wrap:wrap">
                <input type="text" id="meta-name" placeholder="剧本名称（必填）" style="flex:1;min-width:220px;padding:10px;border:1px solid var(--border-color);border-radius:8px;background:var(--card-bg-color)">
                <input type="text" id="meta-author" placeholder="作者（可选）" style="flex:1;min-width:220px;padding:10px;border:1px solid var(--border-color);border-radius:8px;background:var(--card-bg-color)">
                <input type="text" id="meta-logo" placeholder="Logo URL（可选）" style="flex:1;min-width:260px;padding:10px;border:1px solid var(--border-color);border-radius:8px;background:var(--card-bg-color)">
                <input type="text" id="meta-version" placeholder="版本号（可选，如 v1.0）" style="flex:1;min-width:160px;padding:10px;border:1px solid var(--border-color);border-radius:8px;background:var(--card-bg-color)">
            </div>
            <div class="input-row" style="margin-top:10px">
                <input type="text" id="meta-description" placeholder="剧本描述（可选）" style="width:100%;padding:10px;border:1px solid var(--border-color);border-radius:8px;background:var(--card-bg-color)">
            </div>
            <div class="input-row" style="display:flex;gap:12px;flex-wrap:wrap;margin-top:10px">
                <input type="text" id="meta-townsfolkName" placeholder="镇民显示名（默认：镇民）" style="flex:1;min-width:180px;padding:10px;border:1px solid var(--border-color);border-radius:8px;background:var(--card-bg-color)" value="镇民">
                <input type="text" id="meta-outsidersName" placeholder="外来者显示名（默认：外来者）" style="flex:1;min-width:180px;padding:10px;border:1px solid var(--border-color);border-radius:8px;background:var(--card-bg-color)" value="外来者">
                <input type="text" id="meta-minionsName" placeholder="爪牙显示名（默认：爪牙）" style="flex:1;min-width:180px;padding:10px;border:1px solid var(--border-color);border-radius:8px;background:var(--card-bg-color)" value="爪牙">
                <input type="text" id="meta-demonsName" placeholder="恶魔显示名（默认：恶魔）" style="flex:1;min-width:180px;padding:10px;border:1px solid var(--border-color);border-radius:8px;background:var(--card-bg-color)" value="恶魔">
            </div>
        </div>

        <div class="generate-section">
            <div class="random-select-panel" style="display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:8px 0">
                <span style="font-weight:600">随机选择工具：</span>
                <label>镇民 <input type="number" id="rand-townsfolk" value="13" min="0" style="width:70px;padding:6px;border:1px solid var(--border-color);border-radius:8px"></label>
                <label>外来者 <input type="number" id="rand-outsiders" value="4" min="0" style="width:70px;padding:6px;border:1px solid var(--border-color);border-radius:8px"></label>
                <label>爪牙 <input type="number" id="rand-minions" value="4" min="0" style="width:70px;padding:6px;border:1px solid var(--border-color);border-radius:8px"></label>
                <label>恶魔 <input type="number" id="rand-demons" value="4" min="0" style="width:70px;padding:6px;border:1px solid var(--border-color);border-radius:8px"></label>
                <label>旅行者 <input type="number" id="rand-travelers" value="0" min="0" style="width:70px;padding:6px;border:1px solid var(--border-color);border-radius:8px"></label>
                <label>传奇 <input type="number" id="rand-fabled" value="0" min="0" style="width:70px;padding:6px;border:1px solid var(--border-color);border-radius:8px"></label>
                <button class="violet-button" onclick="randomSelectRoles()">🎲 按人数随机勾选</button>
                <button class="violet-button" onclick="clearAllSelections()">清空选择</button>
            </div>
            <button class="generate-button" onclick="generateJson()">
                ⚡ 生成JSON文件
            </button>
        </div>

        <!-- 图片预览区域 -->
        <div id="image-preview" class="image-preview"></div>

        <script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>




    <script>
        // 角色列表
        let dirRolesJson = [];

        const townsfolkRoles = [
        {
            "id": "washerwoman",
            "name": "洗衣妇",
            "pinyin": "xiyifu",
            "pinyinsuoxie": "xyf",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/45/Washerwoman.png/180px-Washerwoman.png",
            "ability": "在你的首个夜晚，你会得知两名玩家和一个镇民角色：这两名玩家之一是该角色。",
            "firstNight": 7500,
            "otherNight": 0
        },
        {
            "id": "librarian",
            "name": "图书管理员",
            "pinyin": "tushuguanliyuan",
            "pinyinsuoxie": "tsgly",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/55/Librarian.png/180px-Librarian.png",
            "ability": "在你的首个夜晚，你会得知两名玩家和一个外来者角色：这两名玩家之一是该角色（或者你会得知没有外来者在场）。",
            "firstNight": 7600,
            "otherNight": 0
        },
        {
            "id": "investigator",
            "name": "调查员",
            "pinyin": "diaochayuan",
            "pinyinsuoxie": "dcy",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/cb/Investigator.png/180px-Investigator.png",
            "ability": "在你的首个夜晚，你会得知两名玩家和一个爪牙角色：这两名玩家之一是该角色（或者你会得知没有爪牙在场）。",
            "firstNight": 7700,
            "otherNight": 0
        },
        {
            "id": "chef",
            "name": "厨师",
            "pinyin": "chushi",
            "pinyinsuoxie": "cs",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/e5/Chef.png/180px-Chef.png",
            "ability": "在你的首个夜晚，你会得知场上邻座的邪恶玩家有多少对。",
            "firstNight": 7800,
            "otherNight": 0
        },
        {
            "id": "empath",
            "name": "共情者",
            "pinyin": "gongqingzhe",
            "pinyinsuoxie": "gqz",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/4e/Empath.png/180px-Empath.png",
            "ability": "每个夜晚，你会得知与你邻近的两名存活的玩家中邪恶玩家的数量。",
            "firstNight": 7900,
            "otherNight": 11000
        },
        {
            "id": "fortune_teller",
            "name": "占卜师",
            "pinyin": "zhanbushi",
            "pinyinsuoxie": "zbs",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/6/67/Fortuneteller.png/180px-Fortuneteller.png",
            "ability": "每个夜晚，你要选择两名玩家：你会得知他们之中是否有恶魔。会有一名善良玩家始终被你的能力当作恶魔。",
            "firstNight": 8000,
            "otherNight": 11100
        },
        {
            "id": "undertaker",
            "name": "送葬者",
            "pinyin": "songzangzhe",
            "pinyinsuoxie": "szz",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c7/Undertaker.png/180px-Undertaker.png",
            "ability": "每个夜晚*，你会得知今天白天死于处决的玩家的角色。",
            "firstNight": 0,
            "otherNight": 11300
        },
        {
            "id": "monk",
            "name": "僧侣",
            "pinyin": "senglv",
            "pinyinsuoxie": "sl",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/44/Monk.png/180px-Monk.png",
            "ability": "每个夜晚*，你要选择除你以外的一名玩家：当晚恶魔的负面能力对他无效。",
            "firstNight": 0,
            "otherNight": 2200
        },
        {
            "id": "ravenkeeper",
            "name": "守鸦人",
            "pinyin": "shouyaren",
            "pinyinsuoxie": "syr",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/37/Ravenkeeper.png/180px-Ravenkeeper.png",
            "ability": "如果你在夜晚死亡，你会被唤醒，然后你要选择一名玩家：你会得知他的角色。",
            "firstNight": 0,
            "otherNight": 9800
        },
        {
            "id": "virgin",
            "name": "贞洁者",
            "pinyin": "zhenjiezhe",
            "pinyinsuoxie": "zjz",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/43/Virgin.png/180px-Virgin.png",
            "ability": "当你首次被提名时，如果提名你的玩家是镇民，他立刻被处决。",
            "firstNight": 0,
            "otherNight": 0
        },
        {
            "id": "slayer",
            "name": "猎手",
            "pinyin": "lieshou",
            "pinyinsuoxie": "ls",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/6/6e/Slayer.png/180px-Slayer.png",
            "ability": "每局游戏限一次，你可以在白天时公开选择一名玩家：如果他是恶魔，他死亡。",
            "firstNight": 0,
            "otherNight": 0
        },
        {
            "id": "soldier",
            "name": "士兵",
            "pinyin": "shibing",
            "pinyinsuoxie": "sb",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/7b/Soldier.png/180px-Soldier.png",
            "ability": "恶魔的负面能力对你无效。",
            "firstNight": 0,
            "otherNight": 0
        },
        {
            "id": "mayor",
            "name": "镇长",
            "pinyin": "zhenzhang",
            "pinyinsuoxie": "zz",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/2/20/Mayor.png/180px-Mayor.png",
            "ability": "如果只有三名玩家存活且白天没有人被处决，你的阵营获胜。如果你在夜晚即将死亡，可能会有一名其他玩家代替你死亡。",
            "firstNight": 0,
            "otherNight": 0
        },
        {
            "id": "grandmother",
            "name": "祖母",
            "pinyin": "zumu",
            "pinyinsuoxie": "zm",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/6/66/Grandmother.png/180px-Grandmother.png",
            "ability": "在你的首个夜晚，你会得知一名善良玩家和他的角色。如果恶魔杀死了他，你也会死亡。",
            "firstNight": 8300,
            "otherNight": 9500
        },
        {
            "id": "sailor",
            "name": "水手",
            "pinyin": "shuishou",
            "pinyinsuoxie": "ss",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/ce/Sailor.png/180px-Sailor.png",
            "ability": "每个夜晚，你要选择一名存活的玩家：你或他之一会醉酒直到下个黄昏。你不会死亡。",
            "firstNight": 3500,
            "otherNight": 1000
        },
        {
            "id": "chambermaid",
            "name": "侍女",
            "pinyin": "shinv",
            "pinyinsuoxie": "sn",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/00/Chambermaid.png/180px-Chambermaid.png",
            "ability": "每个夜晚，你要选择除你以外的两名存活的玩家：你会得知他们中有几人在当晚因其自身能力而被唤醒。",
            "firstNight": 12400,
            "otherNight": 14800
        },
        {
            "id": "exorcist",
            "name": "驱魔人",
            "pinyin": "qumoren",
            "pinyinsuoxie": "qmr",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/a/ac/Exorcist.png/180px-Exorcist.png",
            "ability": "每个夜晚*，你要选择一名玩家（与上个夜晚不同）：如果你选中了恶魔，他会得知你是驱魔人，但他当晚不会因其自身能力而被唤醒。",
            "firstNight": 0,
            "otherNight": 4300
        },
        {
            "id": "innkeeper",
            "name": "旅店老板",
            "pinyin": "lvdianlaoban",
            "pinyinsuoxie": "ldlb",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/32/Innkeeper.png/180px-Innkeeper.png",
            "ability": "每个夜晚*，你要选择两名玩家：他们当晚不会死亡，但其中一人会醉酒到下个黄昏。",
            "firstNight": 0,
            "otherNight": 1800
        },
        {
            "id": "gambler",
            "name": "赌徒",
            "pinyin": "dutu",
            "pinyinsuoxie": "dt",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/8a/Gambler.png/180px-Gambler.png",
            "ability": "每个夜晚*，你要选择一名玩家并猜测该玩家的角色：如果你猜错了，你会死亡。",
            "firstNight": 0,
            "otherNight": 2000
        },
        {
            "id": "gossip",
            "name": "造谣者",
            "pinyin": "zaoyaozhe",
            "pinyinsuoxie": "zyz",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/a/a4/Gossip.png/180px-Gossip.png",
            "ability": "每个白天，你可以公开发表一个声明。如果该声明正确，在当晚会有一名玩家死亡。",
            "firstNight": 0,
            "otherNight": 9100
        },
        {
            "id": "courtier",
            "name": "侍臣",
            "pinyin": "shichen",
            "pinyinsuoxie": "sc",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/d9/Courtier.png/180px-Courtier.png",
            "ability": "每局游戏限一次，在夜晚时，你可以选择一个角色：如果该角色在场，该角色之一从当晚开始醉酒三天三夜。",
            "firstNight": 5100,
            "otherNight": 1900
        },
        {
            "id": "professor",
            "name": "教授",
            "pinyin": "jiaoshou",
            "pinyinsuoxie": "js",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/b1/Professor.png/180px-Professor.png",
            "ability": "每局游戏限一次，在夜晚时*，你可以选择一名死亡的玩家：如果他是镇民，你会将他起死回生。",
            "firstNight": 0,
            "otherNight": 10500
        },
        {
            "id": "minstrel",
            "name": "吟游诗人",
            "pinyin": "yinyoushiren",
            "pinyinsuoxie": "yysr",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/6/66/Minstrel.png/180px-Minstrel.png",
            "ability": "当一名爪牙死于处决时，除了你和旅行者以外的所有其他玩家醉酒直到明天黄昏。",
            "firstNight": 0,
            "otherNight": 0
        },
        {
            "id": "tea_lady",
            "name": "茶艺师",
            "pinyin": "chayishi",
            "pinyinsuoxie": "cys",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/bc/Tealady.png/180px-Tealady.png",
            "ability": "如果与你邻近的两名存活的玩家是善良的，他们不会死亡。",
            "firstNight": 0,
            "otherNight": 0
        },
        {
            "id": "pacifist",
            "name": "和平主义者",
            "pinyin": "hepingzhuyizhe",
            "pinyinsuoxie": "hpzyz",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/4a/Pacifist.png/180px-Pacifist.png",
            "ability": "被处决的善良玩家可能不会死亡。",
            "firstNight": 0,
            "otherNight": 0
        },
        {
            "id": "fool",
            "name": "弄臣",
            "pinyin": "nongchen",
            "pinyinsuoxie": "nc",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/70/Fool.png/180px-Fool.png",
            "ability": "当你首次将要死亡时，你不会死亡。",
            "firstNight": 0,
            "otherNight": 0
        },
        {
            "id": "clockmaker",
            "name": "钟表匠",
            "pinyin": "zhongbiaojiang",
            "pinyinsuoxie": "zbj",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/74/Clockmaker.png/180px-Clockmaker.png",
            "ability": "在你的首个夜晚，你会得知恶魔与爪牙之间最近的距离。（邻座的玩家距离为1）",
            "firstNight": 8400,
            "otherNight": 0
        },
        {
            "id": "dreamer",
            "name": "筑梦师",
            "pinyin": "zhumengshi",
            "pinyinsuoxie": "zms",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/2/29/Dreamer.png/180px-Dreamer.png",
            "ability": "每个夜晚，你要选择除你及旅行者以外的一名玩家：你会得知一个善良角色和一个邪恶角色，该玩家是其中一个角色。",
            "firstNight": 8500,
            "otherNight": 11500
        },
        {
            "id": "snake_charmer",
            "name": "舞蛇人",
            "pinyin": "wusheren",
            "pinyinsuoxie": "wsr",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/a/ab/Snakecharmer.png/180px-Snakecharmer.png",
            "ability": "每个夜晚，你要选择一名存活的玩家：如果你选中了恶魔，你和他交换角色和阵营，然后他中毒。",
            "firstNight": 5200,
            "otherNight": 2100
        },
        {
            "id": "mathematician",
            "name": "数学家",
            "pinyin": "shuxuejia",
            "pinyinsuoxie": "sxj",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/06/Mathematician.png/180px-Mathematician.png",
            "ability": "每个夜晚，你会得知有多少名玩家的能力因为其他角色的能力而未正常生效。（从上个黎明到你被唤醒时）",
            "firstNight": 12500,
            "otherNight": 14900
        },
        {
            "id": "flowergirl",
            "name": "卖花女孩",
            "pinyin": "maihuanvhai",
            "pinyinsuoxie": "mhnh",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/5b/Flowergirl.png/180px-Flowergirl.png",
            "ability": "每个夜晚*，你会得知在今天白天时是否有恶魔投过票。",
            "firstNight": 0,
            "otherNight": 11600
        },
        {
            "id": "town_crier",
            "name": "城镇公告员",
            "pinyin": "chengzhengonggaoyuan",
            "pinyinsuoxie": "czggy",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/b7/Towncrier.png/180px-Towncrier.png",
            "ability": "每个夜晚*，你会得知在今天白天时是否有爪牙发起过提名。",
            "firstNight": 0,
            "otherNight": 11700
        },
        {
            "id": "oracle",
            "name": "神谕者",
            "pinyin": "shenyuzhe",
            "pinyinsuoxie": "syz",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/17/Oracle.png/180px-Oracle.png",
            "ability": "每个夜晚*，你会得知有多少名死亡的玩家是邪恶的。",
            "firstNight": 0,
            "otherNight": 11800
        },
        {
            "id": "savant",
            "name": "博学者",
            "pinyin": "boxuezhe",
            "pinyinsuoxie": "bxz",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/53/Savant.png/180px-Savant.png",
            "ability": "每个白天，你可以私下询问说书人以得知两条信息：一个是正确的，一个是错误的。",
            "firstNight": 0,
            "otherNight": 0
        },
        {
            "id": "seamstress",
            "name": "女裁缝",
            "pinyin": "nvcaifeng",
            "pinyinsuoxie": "ncf",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/a/ae/Seamstress.png/180px-Seamstress.png",
            "ability": "每局游戏限一次，在夜晚时，你可以选择除你以外的两名玩家：你会得知他们是否为同一阵营。",
            "firstNight": 8600,
            "otherNight": 11900
            },
            {
            "id": "philosopher",
            "name": "哲学家",
            "pinyin": "zhexuejia",
            "pinyinsuoxie": "zxj",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/e0/Philosopher.png/180px-Philosopher.png",
            "ability": "每局游戏限一次，在夜晚时，你可以选择一个善良角色：你获得该角色的能力。如果这个角色在场，他醉酒。",
            "firstNight": 300,
            "otherNight": 400
            },
            {
            "id": "artist",
            "name": "艺术家",
            "pinyin": "yishujia",
            "pinyinsuoxie": "ysj",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/a/a5/Artist.png/180px-Artist.png",
            "ability": "每局游戏限一次，在白天时，你可以私下询问说书人一个是非问题，你会得知该问题的答案。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "juggler",
            "name": "杂耍艺人",
            "pinyin": "zashuayiren",
            "pinyinsuoxie": "zsyr",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/be/Juggler.png/180px-Juggler.png",
            "ability": "在你的首个白天，你可以公开猜测任意玩家的角色最多五次。在当晚，你会得知猜测正确的角色数量。",
            "firstNight": 0,
            "otherNight": 12000
            },
            {
            "id": "sage",
            "name": "贤者",
            "pinyin": "xianzhe",
            "pinyinsuoxie": "xz",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/f/f8/Sage.png/180px-Sage.png",
            "ability": "如果恶魔杀死了你，在当晚你会被唤醒并得知两名玩家，其中一名是杀死你的那个恶魔。",
            "firstNight": 0,
            "otherNight": 9900
            },
            {
            "id": "lycanthrope",
            "name": "半兽人",
            "pinyin": "banshouren",
            "pinyinsuoxie": "bsr",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c1/Lycanthrope.png/180px-Lycanthrope.png",
            "ability": "每个夜晚*，你要选择一名存活玩家：如果他是善良的，他死亡，并且当晚恶魔不会造成死亡。会有一名善良玩家始终被当作邪恶阵营。",
            "firstNight": 0,
            "otherNight": 4400
            },
            {
            "id": "banshee",
            "name": "报丧女妖",
            "pinyin": "baosangnvyao",
            "pinyinsuoxie": "bsny",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/d3/Banshee.png/180px-Banshee.png",
            "ability": "如果恶魔杀死了你，所有玩家都会得知此事。从现在开始，你每天可以发起两次提名，每次投票时可以投两票。",
            "firstNight": 0,
            "otherNight": 10400
            },
            {
            "id": "choirboy",
            "name": "唱诗男孩",
            "pinyin": "changshinanhai",
            "pinyinsuoxie": "csnh",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/f/f3/Choirboy.png/180px-Choirboy.png",
            "ability": "如果恶魔杀死了国王，你会得知哪名玩家是恶魔。[+国王]",
            "firstNight": 0,
            "otherNight": 10200
            },
            {
            "id": "preacher",
            "name": "传教士",
            "pinyin": "chuanjiaoshi",
            "pinyinsuoxie": "cjs",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/44/Preacher.png/180px-Preacher.png",
            "ability": "每个夜晚，你要选择一名玩家：如果你选中了爪牙，他会得知被传教士选中。所有被你选中的爪牙失去能力。",
            "firstNight": 4200,
            "otherNight": 1200
            },
            {
            "id": "village_idiot",
            "name": "村夫",
            "pinyin": "cunfu",
            "pinyinsuoxie": "cf",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/78/Villageidiot.png/180px-Villageidiot.png",
            "ability": "每个夜晚，你要选择一名玩家：你会得知他的阵营。[+0~2村夫，复数村夫中有一人醉酒]",
            "firstNight": 10100,
            "otherNight": 12800
            },
            {
            "id": "engineer",
            "name": "工程师",
            "pinyin": "gongchengshi",
            "pinyinsuoxie": "gcs",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/d8/Engineer.png/180px-Engineer.png",
            "ability": "每局游戏限一次，在夜晚时，你可以选择让恶魔变成你选择的恶魔角色，或让所有爪牙变成你选择的爪牙角色。",
            "firstNight": 4100,
            "otherNight": 1100
            },
            {
            "id": "noble",
            "name": "贵族",
            "pinyin": "guizu",
            "pinyinsuoxie": "gz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/59/Noble.png/180px-Noble.png",
            "ability": "在你的首个夜晚，你会得知三名玩家：其中有且只有一名玩家是邪恶的。",
            "firstNight": 8900,
            "otherNight": 0
            },
            {
            "id": "king",
            "name": "国王",
            "pinyin": "guowang",
            "pinyinsuoxie": "gw",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/1d/King.png/180px-King.png",
            "ability": "每个夜晚，如果死亡的玩家数量大于或等于存活的玩家数量，你会得知一个存活的角色。恶魔知道你是国王。",
            "firstNight": 3100,
            "otherNight": 13100
            },
            {
            "id": "general",
            "name": "将军",
            "pinyin": "jiangjun",
            "pinyinsuoxie": "jj",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/6/6d/General.png/180px-General.png",
            "ability": "每个夜晚，你会得知说书人认为哪个阵营当前更有优势（善良/邪恶/均势）。",
            "firstNight": 12300,
            "otherNight": 14700
            },
            {
            "id": "alchemist",
            "name": "炼金术士",
            "pinyin": "lianjinshushi",
            "pinyinsuoxie": "ljss",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/5b/Alchemist.png/180px-Alchemist.png",
            "ability": "你拥有一个爪牙角色的能力。当你使用能力时，说书人可能会要求你更换选择。",
            "firstNight": 600,
            "otherNight": 0
            },
            {
            "id": "magician",
            "name": "魔术师",
            "pinyin": "moshushi",
            "pinyinsuoxie": "mss",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/ca/Magician.png/180px-Magician.png",
            "ability": "恶魔会以为你是爪牙。爪牙会以为你是恶魔。",
            "firstNight": 1100,
            "otherNight": 0
            },
            {
            "id": "farmer",
            "name": "农夫",
            "pinyin": "nongfu",
            "pinyinsuoxie": "nf",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/3d/Farmer.png/180px-Farmer.png",
            "ability": "当你在夜晚死亡时，一名存活的善良玩家会变成农夫。",
            "firstNight": 0,
            "otherNight": 10300
            },
            {
            "id": "high_priestess",
            "name": "女祭司",
            "pinyin": "nvjisi",
            "pinyinsuoxie": "njs",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/86/Highpriestess.png/180px-Highpriestess.png",
            "ability": "每个夜晚，你会得知一名说书人认为你最应该与其交流的玩家。",
            "firstNight": 11900,
            "otherNight": 14500
            },
            {
            "id": "balloonist",
            "name": "气球驾驶员",
            "pinyin": "qiqiujiashiyuan",
            "pinyinsuoxie": "qqjsy",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/35/Balloonist.png/180px-Balloonist.png",
            "ability": "每个夜晚，你会得知一名与上个夜晚得知的玩家角色类型不同的玩家。[+0~1外来者]",
            "firstNight": 9000,
            "otherNight": 12100
            },
            {
            "id": "knight",
            "name": "骑士",
            "pinyin": "qishi",
            "pinyinsuoxie": "qs",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/6/6b/Knight.png/180px-Knight.png",
            "ability": "在你的首个夜晚，你会得知两名非恶魔玩家。",
            "firstNight": 8800,
            "otherNight": 0
            },
            {
            "id": "bounty_hunter",
            "name": "赏金猎人",
            "pinyin": "shangjinlieren",
            "pinyinsuoxie": "sjlr",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/ee/Bountyhunter.png/180px-Bountyhunter.png",
            "ability": "在你的首个夜晚，你会得知一名邪恶玩家。每当你得知的玩家死亡，你会在当晚得知另一名邪恶玩家。[会有一名镇民转变为邪恶阵营]",
            "firstNight": 10600,
            "otherNight": 13300
            },
            {
            "id": "amnesiac",
            "name": "失忆者",
            "pinyin": "shiyizhe",
            "pinyinsuoxie": "syz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/55/Amnesiac.png/180px-Amnesiac.png",
            "ability": "你不知道你的能力是什么。每个白天你可以找说书人猜测一次，你会得知你的猜测有多准确。",
            "firstNight": 200,
            "otherNight": 300
            },
            {
            "id": "cannibal",
            "name": "食人族",
            "pinyin": "shirenzu",
            "pinyinsuoxie": "srz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/ed/Cannibal.png/180px-Cannibal.png",
            "ability": "你拥有上个死于处决的玩家的能力。如果该玩家属于邪恶阵营，你中毒直到下个善良玩家死于处决。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "steward",
            "name": "事务官",
            "pinyin": "shiwuguan",
            "pinyinsuoxie": "swg",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/ee/Steward.png/180px-Steward.png",
            "ability": "在你的首个夜晚，你会得知一名善良玩家。",
            "firstNight": 8700,
            "otherNight": 0
            },
            {
            "id": "nightwatchman",
            "name": "守夜人",
            "pinyin": "shouyeren",
            "pinyinsuoxie": "syr",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/3f/Nightwatchman.png/180px-Nightwatchman.png",
            "ability": "每局游戏限一次，在夜晚时，你可以选择一名玩家：他会得知你是守夜人。",
            "firstNight": 10700,
            "otherNight": 13400
            },
            {
            "id": "atheist",
            "name": "无神论者",
            "pinyin": "wushenlunzhe",
            "pinyinsuoxie": "wslz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/d7/Atheist.png/180px-Atheist.png",
            "ability": "说书人可以打破游戏规则，如果说书人被处决，善良阵营获胜，即使你已死亡。[无邪恶角色在场]",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "alsaahir",
            "name": "戏法师",
            "pinyin": "xifashi",
            "pinyinsuoxie": "xfs",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/d6/Alsaahir.png/180px-Alsaahir.png",
            "ability": "每个白天，你可以公开进行一次谁是爪牙，谁是恶魔的猜测。如果你猜对，善良阵营获胜。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "pixie",
            "name": "小精灵",
            "pinyin": "xiaojingling",
            "pinyinsuoxie": "xjl",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/2/22/Pixie.png/180px-Pixie.png",
            "ability": "在你的首个夜晚，你会得知一个在场的镇民角色。如果你\"疯狂\"地证明你是该角色，当他死亡时你获得该角色的能力。",
            "firstNight": 7300,
            "otherNight": 0
            },
            {
            "id": "shugenja",
            "name": "修行者",
            "pinyin": "xiuxingzhe",
            "pinyinsuoxie": "xxz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/3e/Shugenja.png/180px-Shugenja.png",
            "ability": "在你的首个夜晚，你会得知距离最近的邪恶玩家位于你的顺时针还是逆时针方向。如果两侧的邪恶玩家与你距离相等，你得知的信息由说书人决定。",
            "firstNight": 12000,
            "otherNight": 0
            },
            {
            "id": "huntsman",
            "name": "巡山人",
            "pinyin": "xunshanren",
            "pinyinsuoxie": "xsr",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/75/Huntsman.png/180px-Huntsman.png",
            "ability": "每局游戏限一次，在夜晚时，你可以选择一名存活的玩家：如果你选中了落难少女，她会变成一个不在场的镇民角色。[+落难少女]",
            "firstNight": 7400,
            "otherNight": 10900
            },
            {
            "id": "cult_leader",
            "name": "异教领袖",
            "pinyin": "yijiaolingxiu",
            "pinyinsuoxie": "yjlx",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/e1/Cultleader.png/180px-Cultleader.png",
            "ability": "每个夜晚，你会转变为与你邻近的一名存活的玩家的阵营。每个白天，你可以提议所有玩家加入你的教派，如果所有善良玩家同意加入，你的阵营获胜。",
            "firstNight": 11600,
            "otherNight": 14200
            },
            {
            "id": "poppy_grower",
            "name": "罂粟种植者",
            "pinyin": "yingsuzhongzhizhe",
            "pinyinsuoxie": "yszzz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/42/Poppygrower.png/180px-Poppygrower.png",
            "ability": "爪牙和恶魔互相不认识。如果你死亡，当晚他们会互相认识。",
            "firstNight": 700,
            "otherNight": 900
            },
            {
            "id": "fisherman",
            "name": "渔夫",
            "pinyin": "yufu",
            "pinyinsuoxie": "yf",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/f/f0/Fisherman.png/180px-Fisherman.png",
            "ability": "每局游戏限一次，在白天时，你可以让说书人给你一些能帮助你的阵营获胜的建议。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "acrobat",
            "name": "杂技演员",
            "pinyin": "zajiyanyuan",
            "pinyinsuoxie": "zjyy",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/8f/Acrobat.png/180px-Acrobat.png",
            "ability": "每个夜晚*，你要选择一名玩家：如果当晚他醉酒或中毒，你死亡。",
            "firstNight": 0,
            "otherNight": 2050
            },
            {
            "id": "banxian",
            "name": "半仙",
            "pinyin": "banxian",
            "pinyinsuoxie": "bx",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/b7/Banxian.png/180px-Banxian.png",
            "ability": "任何在夜晚使用自身能力选择你的其他玩家，会改为选中另一名邪恶玩家作为替代。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "bianlianshi",
            "name": "变脸师",
            "pinyin": "bianlianshi",
            "pinyinsuoxie": "bls",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/49/Bianlianshi.png/180px-Bianlianshi.png",
            "ability": "每个白天，如果你\"疯狂\"地证明自己是一个善良角色（与之前不同），你可能会在当晚获得那个角色的能力，直到下个黄昏。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "dagengren",
            "name": "打更人",
            "pinyin": "dagengren",
            "pinyinsuoxie": "dgr",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/db/Dagengren.png/180px-Dagengren.png",
            "ability": "每个夜晚*，你要猜测今晚首个死亡的玩家与你的距离。如果你猜测正确，则除你以外的所有玩家今晚不会死亡，但你可能会死亡。",
            "firstNight": 0,
            "otherNight": 1960
            },
            {
            "id": "dianxiaoer",
            "name": "店小二",
            "pinyin": "dianxiaoer",
            "pinyinsuoxie": "dxe",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/8d/Dianxiaoer.png/180px-Dianxiaoer.png",
            "ability": "在你的首个夜晚，你会得知两名善良玩家。他们之中会有一人醉酒，即使你已死亡。",
            "firstNight": 9400,
            "otherNight": 0
            },
            {
            "id": "geling",
            "name": "歌伶",
            "pinyin": "geling",
            "pinyinsuoxie": "gl",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/54/Geling.png/180px-Geling.png",
            "ability": "每局游戏限一次，在白天时，你可以提议所有玩家观看你的演出，并从同意参加的玩家中选择你的观众。如果恶魔成为了观众，你会在当晚死亡。",
            "firstNight": 0,
            "otherNight": 9000
            },
            {
            "id": "heshang",
            "name": "和尚",
            "pinyin": "heshang",
            "pinyinsuoxie": "hs",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/a/ae/Heshang.png/180px-Heshang.png",
            "ability": "每个夜晚，当有邪恶玩家的能力首次选择或影响与你邻近的存活玩家时，改为此次能力不生效并持续至下个黎明，且你会得知你的能力被触发。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "jinyiwei",
            "name": "锦衣卫",
            "pinyin": "jinyiwei",
            "pinyinsuoxie": "jiw",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/38/Jinyiwei.png/180px-Jinyiwei.png",
            "ability": "每个夜晚*，你要选择一名玩家：如果他在下个黄昏前死亡，你代替他死亡。",
            "firstNight": 0,
            "otherNight": 1970
            },
            {
            "id": "langzhong",
            "name": "郎中",
            "pinyin": "langzhong",
            "pinyinsuoxie": "lz",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/eb/Langzhong.png/180px-Langzhong.png",
            "ability": "每个夜晚，你要选择除你以外的一名玩家：你会得知一个与他能力相关的词语。",
            "firstNight": 9300,
            "otherNight": 12200
            },
            {
            "id": "qintianjian",
            "name": "钦天监",
            "pinyin": "qintianjian",
            "pinyinsuoxie": "qtj",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/13/Qintianjian.png/180px-Qintianjian.png",
            "ability": "在你的首个夜晚，你会得知离你最近的邪恶玩家位于你的哪一侧（左/右/相同）。如果与你邻近的玩家中有邪恶阵营，你会得知错误信息作为替代。",
            "firstNight": 12100,
            "otherNight": 0
            },
            {
            "id": "wudaozhe",
            "name": "悟道者",
            "pinyin": "wudaozhe",
            "pinyinsuoxie": "wdz",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/a/a7/Wudaozhe.png/180px-Wudaozhe.png",
            "ability": "你以为你是一个外来者，但你实际上不是。如果有邪恶玩家的能力选择或影响了你，你会立即变成一个不在场的镇民角色。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "xizi",
            "name": "戏子",
            "pinyin": "xizi",
            "pinyinsuoxie": "xz",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/13/Xizi.png/180px-Xizi.png",
            "ability": "所有戏子互相认识。不论在场的戏子数量多少或存活与否，胜负结果会被对调。[所有善良玩家都是戏子]",
            "firstNight": 3400,
            "otherNight": 0
            },
            {
            "id": "xionghaizi",
            "name": "熊孩子",
            "pinyin": "xionghaizi",
            "pinyinsuoxie": "xhz",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/7a/Xionghaizi.png/180px-Xionghaizi.png",
            "ability": "每个夜晚，你要选择一个镇民角色：他的能力会产生错误信息，直到下个黄昏。",
            "firstNight": 7200,
            "otherNight": 2500
            },
            {
            "id": "yinyangshi",
            "name": "阴阳师",
            "pinyin": "yinyangshi",
            "pinyinsuoxie": "yys",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/d2/Yinyangshi.png/180px-Yinyangshi.png",
            "ability": "在你的首个夜晚，你会得知两个善良角色和两个邪恶角色，其中有且只有两个角色在场。",
            "firstNight": 9200,
            "otherNight": 0
            },
            {
            "id": "bingbi",
            "name": "秉笔",
            "pinyin": "bingbi",
            "pinyinsuoxie": "bb",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/2/2b/Bingbi.png/180px-Bingbi.png",
            "ability": "如果你在白天死亡，当晚你会得知一名善良玩家。如果你在夜晚死亡，当晚你会得知一名邪恶玩家。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "chongfei",
            "name": "宠妃",
            "pinyin": "chongfei",
            "pinyinsuoxie": "cf",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/30/Chongfei.png/180px-Chongfei.png",
            "ability": "每局游戏限一次，说书人会在关于你的事情上打破规则。随后，你会秘密得知说书人为此做了什么。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "daoke",
            "name": "刀客",
            "pinyin": "daoke",
            "pinyinsuoxie": "dk",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/44/Daoke.png/180px-Daoke.png",
            "ability": "在你的首个夜晚，你会得知一个在场的爪牙角色。每局游戏限一次，你可以在白天公开选择一名玩家：如果他是你得知的角色，他死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "daoshi",
            "name": "道士",
            "pinyin": "daoshi",
            "pinyinsuoxie": "ds",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/07/Daoshi.png/180px-Daoshi.png",
            "ability": "每个夜晚*，你要选择一名玩家：如果你选中了恶魔，你死亡，然后他醉酒直到下个黎明。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "fangshi",
            "name": "方士",
            "pinyin": "fangshi",
            "pinyinsuoxie": "fs",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/f/f5/Fangshi.png/180px-Fangshi.png",
            "ability": "在你的首个夜晚，你要选择一个数字。在该数字对应的那一个夜晚，你会得知对应数量的在场角色。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "fengshuishi",
            "name": "风水师",
            "pinyin": "fengshuishi",
            "pinyinsuoxie": "fss",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/73/Fengshuishi.png/180px-Fengshuishi.png",
            "ability": "在你的首个夜晚，你会得知一名玩家的角色类型。每个夜晚*，你会从他的顺时针方向得知下一名非旅行者玩家的角色类型。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "limao",
            "name": "狸猫",
            "pinyin": "limao",
            "pinyinsuoxie": "lm",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/a/a6/Limao.png/180px-Limao.png",
            "ability": "每个夜晚*，你要选择一名玩家：如果他是善良角色且当晚被邪恶角色杀死，你和他交换角色。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "qianke",
            "name": "掮客",
            "pinyin": "qianke",
            "pinyinsuoxie": "qk",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/5b/Qianke.png/180px-Qianke.png",
            "ability": "每个夜晚，你要选择两名存活玩家：如果他们阵营相同，今晚任何玩家使用自身能力选择他们之一作为目标时，改为选中另一名玩家。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "ranfangfangzhu",
            "name": "染坊坊主",
            "pinyin": "ranfangfangzhu",
            "pinyinsuoxie": "rffz",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/05/Ranfangfangzhu.png/180px-Ranfangfangzhu.png",
            "ability": "如果你在夜晚死亡，恶魔的能力变成\"每个夜晚*，可能会有一名玩家死亡。\"",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "shiguan",
            "name": "史官",
            "pinyin": "shiguan",
            "pinyinsuoxie": "sg",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/8a/Shiguan.png/180px-Shiguan.png",
            "ability": "每个夜晚*，如果今天白天有玩家死于处决，你会得知存活镇民的数量。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "tixingguan",
            "name": "提刑官",
            "pinyin": "tixingguan",
            "pinyinsuoxie": "txg",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/15/Tixingguan.png/180px-Tixingguan.png",
            "ability": "在你首次提名玩家后，你会在当晚得知他的角色。恶魔会被你的能力当作善良角色。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "xuncha",
            "name": "巡查",
            "pinyin": "xuncha",
            "pinyinsuoxie": "xc",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/cf/Xuncha.png/180px-Xuncha.png",
            "ability": "每个夜晚*，你要选择两个善良角色（与上个夜晚不同）：如果他们都存活，他们当晚不会死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "yanshi",
            "name": "偃师",
            "pinyin": "yanshi",
            "pinyinsuoxie": "ys",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/d4/Yanshi.png/180px-Yanshi.png",
            "ability": "如果你在夜晚死亡，你与一名存活爪牙玩家交换角色。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "yishi",
            "name": "驿使",
            "pinyin": "yishi",
            "pinyinsuoxie": "ys",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/6/64/Yishi.png/180px-Yishi.png",
            "ability": "每个白天，你可以公开声明一个角色。在当晚，你会得知该角色是否在场。如果你因此得知了否，你失去此能力。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "yinluren",
            "name": "引路人",
            "pinyin": "yinluren",
            "pinyinsuoxie": "ylr",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/03/Yinluren.png/180px-Yinluren.png",
            "ability": "每个夜晚，你要选择至多三名玩家：你会得知今晚是否有邪恶玩家的能力选择或影响了他们之中的玩家。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "yongjiang",
            "name": "俑匠",
            "pinyin": "yongjiang",
            "pinyinsuoxie": "yj",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/47/Yongjiang.png/180px-Yongjiang.png",
            "ability": "如果已死亡玩家中没有邪恶玩家，你只会死于处决。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "zhen",
            "name": "鸩",
            "pinyin": "zhen",
            "pinyinsuoxie": "z",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/43/Zhen.png/180px-Zhen.png",
            "ability": "每局游戏限一次，在夜晚时*，你可以选择一个镇民角色：如果他在场，他中毒并死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "zhifu",
            "name": "知府",
            "pinyin": "zhifu",
            "pinyinsuoxie": "zf",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c5/Zhifu.png/180px-Zhifu.png",
            "ability": "每个夜晚*，你会得知今天是否有非镇民且非旅行者的玩家死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "xizi_new",
            "name": "戏子（改）",
            "pinyin": "xizigai",
            "pinyinsuoxie": "xzg",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/13/Xizi.png/180px-Xizi.png",
            "ability": "其他善良玩家醉酒（旅行者除外），你们互相认识且无法转变阵营，对调胜负结果，即使你失去能力。",
            "firstNight": 3410,
            "otherNight": 0
            },
            {
            "id": "oldking",
            "name": "旧国王",
            "pinyin": "jiuguowang",
            "pinyinsuoxie": "jgw",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/1d/King.png/180px-King.png",
            "ability": "",
            "firstNight": 3110,
            "otherNight": 13110
            },
            {
            "id": "oldballoonist",
            "name": "旧气球驾驶员",
            "pinyin": "jiuqiqiujianshiyuan",
            "pinyinsuoxie": "jqjqjs",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/35/Balloonist.png/180px-Balloonist.png",
            "ability": "",
            "firstNight": 9010,
            "otherNight": 12110
            },
            {
            "id": "oldfarmer",
            "name": "旧农夫",
            "pinyin": "jiunongfu",
            "pinyinsuoxie": "jnf",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/3d/Farmer.png/180px-Farmer.png",
            "ability": "",
            "firstNight": 0,
            "otherNight": 10310
            },
            {
            "id": "oldalsaahir",
            "name": "旧戏法师",
            "pinyin": "jiuxifashi",
            "pinyinsuoxie": "jxfs",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/d6/Alsaahir.png/180px-Alsaahir.png",
            "ability": "",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "oldlycanthrope",
            "name": "旧半兽人",
            "pinyin": "jiubanshouren",
            "pinyinsuoxie": "jbsr",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c1/Lycanthrope.png/180px-Lycanthrope.png",
            "ability": "",
            "firstNight": 0,
            "otherNight": 4410
            },
            {
            "id": "oldalchemist",
            "name": "旧炼金术士",
            "pinyin": "jiulianjinshushi",
            "pinyinsuoxie": "jljss",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/5b/Alchemist.png/180px-Alchemist.png",
            "ability": "",
            "firstNight": 610,
            "otherNight": 0
            }
        ]



        const outsidersRoles = [
        {
            "id": "butler",
            "name": "管家",
            "pinyin": "guanjia",
            "pinyinsuoxie": "gj",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/82/Butler.png/180px-Butler.png",
            "ability": "每个夜晚，你要选择除你以外的一名玩家：明天白天，只有他投票时你才能投票。",
            "firstNight": 8100,
            "otherNight": 11200
            },
            {
            "id": "drunk",
            "name": "酒鬼",
            "pinyin": "jiugui",
            "pinyinsuoxie": "jg",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/14/Drunk.png/180px-Drunk.png",
            "ability": "你不知道你是酒鬼。你以为你是一个镇民角色，但其实你不是。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "recluse",
            "name": "陌客",
            "pinyin": "moke",
            "pinyinsuoxie": "mk",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/02/Recluse.png/180px-Recluse.png",
            "ability": "你可能会被当作邪恶阵营、爪牙角色或恶魔角色，即使你已死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "saint",
            "name": "圣徒",
            "pinyin": "shengtu",
            "pinyinsuoxie": "st",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/bc/Saint.png/180px-Saint.png",
            "ability": "如果你死于处决，你的阵营落败。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "tinker",
            "name": "修补匠",
            "pinyin": "xiubujiang",
            "pinyinsuoxie": "xbj",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/ec/Tinker.png/180px-Tinker.png",
            "ability": "你随时可能死亡。",
            "firstNight": 0,
            "otherNight": 9200
            },
            {
            "id": "moonchild",
            "name": "月之子",
            "pinyin": "yuezhizi",
            "pinyinsuoxie": "yzz",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/7d/Moonchild.png/180px-Moonchild.png",
            "ability": "当你得知你死亡时，你要公开选择一名存活的玩家。如果他是善良的，在当晚他会死亡。",
            "firstNight": 0,
            "otherNight": 9300
            },
            {
            "id": "goon",
            "name": "莽夫",
            "pinyin": "mangfu",
            "pinyinsuoxie": "mf",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/cd/Goon.png/180px-Goon.png",
            "ability": "每个夜晚，首个使用其自身能力选择了你的玩家会醉酒直到下个黄昏。你会转变为他的阵营。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "lunatic",
            "name": "疯子",
            "pinyin": "fengzi",
            "pinyinsuoxie": "fz",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/89/Lunatic.png/180px-Lunatic.png",
            "ability": "你以为你是一个恶魔，但其实你不是。恶魔知道你是疯子以及你在每个夜晚选择了哪些玩家。",
            "firstNight": 2300,
            "otherNight": 4200
            },
            {
            "id": "mutant",
            "name": "畸形秀演员",
            "pinyin": "jixingxiuyanyuan",
            "pinyinsuoxie": "jxxyy",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/58/Mutant.png/180px-Mutant.png",
            "ability": "如果你\"疯狂\"地证明自己是外来者，你可能被处决。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "sweetheart",
            "name": "心上人",
            "pinyin": "xinshangren",
            "pinyinsuoxie": "xsr",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c2/Sweetheart.png/180px-Sweetheart.png",
            "ability": "当你死亡时，会有一名玩家开始醉酒。",
            "firstNight": 0,
            "otherNight": 9700
            },
            {
            "id": "barber",
            "name": "理发师",
            "pinyin": "lifashi",
            "pinyinsuoxie": "lfs",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/3a/Barber.png/180px-Barber.png",
            "ability": "如果你死亡，在当晚恶魔可以选择两名玩家（不能选择其他恶魔）交换角色。",
            "firstNight": 0,
            "otherNight": 9600
            },
            {
            "id": "klutz",
            "name": "呆瓜",
            "pinyin": "daigua",
            "pinyinsuoxie": "dg",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/f/f6/Klutz.png/180px-Klutz.png",
            "ability": "当你得知你死亡时，你要公开选择一名存活的玩家：如果他是邪恶的，你的阵营落败。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "snitch",
            "name": "告密者",
            "pinyin": "gaomizhe",
            "pinyinsuoxie": "gmz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/0c/Snitch.png/180px-Snitch.png",
            "ability": "爪牙会在其首个夜晚得知三个伪装。",
            "firstNight": 2100,
            "otherNight": 0
            },
            {
            "id": "puzzlemaster",
            "name": "解谜大师",
            "pinyin": "jiemidashi",
            "pinyinsuoxie": "jmds",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/1b/Puzzlemaster.png/180px-Puzzlemaster.png",
            "ability": "一名玩家醉酒，即使你已死亡。每局游戏限一次，你可以猜测谁是那个醉酒的玩家，如果猜对了，你会得知谁是恶魔，但如果猜错了，你会得知错误的\"谁是恶魔\"信息。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "zealot",
            "name": "狂热者",
            "pinyin": "kuangrezhe",
            "pinyinsuoxie": "krz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/1a/Zealot.png/180px-Zealot.png",
            "ability": "如果有大于等于五名玩家存活，你必须在所有提名中投票。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "damsel",
            "name": "落难少女",
            "pinyin": "luonanshaonv",
            "pinyinsuoxie": "lnsn",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/b6/Damsel.png/180px-Damsel.png",
            "ability": "所有爪牙都知道落难少女在场。每局游戏限一次，任意爪牙可以公开猜测你是落难少女，如果猜对，你的阵营落败。",
            "firstNight": 2200,
            "otherNight": 0
            },
            {
            "id": "hatter",
            "name": "帽匠",
            "pinyin": "maojiang",
            "pinyinsuoxie": "mj",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/ee/Hatter.png/180px-Hatter.png",
            "ability": "如果你死亡，当晚爪牙和恶魔玩家可以选择变成新的爪牙和恶魔角色。",
            "firstNight": 0,
            "otherNight": 800
            },
            {
            "id": "golem",
            "name": "魔像",
            "pinyin": "moxiang",
            "pinyinsuoxie": "mx",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/ce/Golem.png/180px-Golem.png",
            "ability": "每局游戏你只能发起提名一次。当你发起提名时，如果被你提名的玩家不是恶魔，他死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "ogre",
            "name": "食人魔",
            "pinyin": "shirenmo",
            "pinyinsuoxie": "srm",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c5/Ogre.png/180px-Ogre.png",
            "ability": "在你的首个夜晚，你要选择除你以外的一名玩家：你转变为他的阵营，即使你已醉酒或中毒，但你不知道你转变后的阵营。",
            "firstNight": 11750,
            "otherNight": 0
            },
            {
            "id": "plague_doctor",
            "name": "瘟疫医生",
            "pinyin": "wenyiyisheng",
            "pinyinsuoxie": "wyys",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/2/2d/Plaguedoctor.png/180px-Plaguedoctor.png",
            "ability": "当你死亡时，说书人会获得一个爪牙能力。",
            "firstNight": 0,
            "otherNight": 10000
            },
            {
            "id": "heretic",
            "name": "异端分子",
            "pinyin": "yiduanfenzi",
            "pinyinsuoxie": "ydfz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/81/Heretic.png/180px-Heretic.png",
            "ability": "对调胜负结果，即使你已死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "politician",
            "name": "政客",
            "pinyin": "zhengke",
            "pinyinsuoxie": "zk",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/9/91/Politician.png/180px-Politician.png",
            "ability": "如果你是对你的阵营落败负最大责任的人，你转变阵营并获胜，即使你已死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "nichen",
            "name": "逆臣",
            "pinyin": "nichen",
            "pinyinsuoxie": "nc",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/51/Nichen.png/180px-Nichen.png",
            "ability": "在你的首个夜晚，你要选择除你以外的一名玩家：如果他先死于处决，你会在当晚转变为邪恶；如果你先死于处决，他会在当晚转变为邪恶。",
            "firstNight": 8200,
            "otherNight": 3400
            },
            {
            "id": "shaxing",
            "name": "煞星",
            "pinyin": "shaxing",
            "pinyinsuoxie": "sx",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/b9/Shaxing.png/180px-Shaxing.png",
            "ability": "如果你死亡，当晚与你邻近的存活玩家之一可能会死亡。",
            "firstNight": 0,
            "otherNight": 9400
            },
            {
            "id": "shijie",
            "name": "使节",
            "pinyin": "shijie",
            "pinyinsuoxie": "sj",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/6/67/Shijie.png/180px-Shijie.png",
            "ability": "每个夜晚限一次，一名玩家在使用自身能力选择邪恶玩家时会改为选中你，即使你已死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "shusheng",
            "name": "书生",
            "pinyin": "shusheng",
            "pinyinsuoxie": "ss",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/db/Shusheng.png/180px-Shusheng.png",
            "ability": "恶魔知道书生在场。每局游戏限一次，恶魔可以拜访说书人并猜测你是书生。如果恶魔猜测正确，即使你已死亡，当晚该恶魔可以选择一名玩家：他死亡。",
            "firstNight": 3300,
            "otherNight": 8500
            },
            {
            "id": "jiubao",
            "name": "酒保",
            "pinyin": "jiubao",
            "pinyinsuoxie": "jb",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c2/Jiubao.png/180px-Jiubao.png",
            "ability": "与你邻近的善良玩家之一醉酒，即使你已死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "rulianshi",
            "name": "入殓师",
            "pinyin": "rulianshi",
            "pinyinsuoxie": "rls",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/9/9b/Rulianshi.png/180px-Rulianshi.png",
            "ability": "如果你提名了恶魔且他死于这次处决，你会变成那个邪恶的恶魔。当剩余存活玩家小于等于四人时（旅行者除外），你失去能力。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "shutong",
            "name": "书童",
            "pinyin": "shutong",
            "pinyinsuoxie": "st",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/f/f6/Shutong.png/180px-Shutong.png",
            "ability": "在你的首个夜晚，你要选择除你以外的一名玩家：除首个夜晚以外，当他被邪恶玩家的能力选择或影响时，你会在当晚死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "oldplague_doctor",
            "name": "旧瘟疫医生",
            "pinyin": "jiuwenyiyisheng",
            "pinyinsuoxie": "jwyys",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/2/2d/Plaguedoctor.png/180px-Plaguedoctor.png",
            "ability": "",
            "firstNight": 0,
            "otherNight": 10020
            },
            {
            "id": "oldacrobat",
            "name": "旧杂技演员",
            "pinyin": "jiuzajiyanyuan",
            "pinyinsuoxie": "jzjyy",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/8f/Acrobat.png/180px-Acrobat.png",
            "ability": "",
            "firstNight": 0,
            "otherNight": 8900
            }
        ]



        const minionsRoles = [
        {
            "id": "poisoner",
            "name": "投毒者",
            "pinyin": "touduzhe",
            "pinyinsuoxie": "tdz",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/74/Poisoner.png/180px-Poisoner.png",
            "ability": "每个夜晚，你要选择一名玩家：他在当晚和明天白天中毒。",
            "firstNight": 4600,
            "otherNight": 1400
        },

        {
            "id": "spy",
            "name": "间谍",
            "pinyin": "jiandie",
            "pinyinsuoxie": "jd",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/36/Spy.png/180px-Spy.png",
            "ability": "每个夜晚，你能查看魔典。你可能会被当作善良阵营、镇民角色或外来者角色，即使你已死亡。",
            "firstNight": 11700,
            "otherNight": 14400
            },
            {
            "id": "scarlet_woman",
            "name": "红唇女郎",
            "pinyin": "hongchunnvlang",
            "pinyinsuoxie": "hcnl",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/a/ac/Scarletwoman.png/180px-Scarletwoman.png",
            "ability": "如果大于等于五名玩家存活时（旅行者不计算在内）恶魔死亡，你变成那个恶魔。",
            "firstNight": 0,
            "otherNight": 3700
            },
            {
            "id": "baron",
            "name": "男爵",
            "pinyin": "nanjue",
            "pinyinsuoxie": "nj",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/40/Baron.png/180px-Baron.png",
            "ability": "会有额外的外来者在场。[+2 外来者]",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "godfather",
            "name": "教父",
            "pinyin": "jiaofu",
            "pinyinsuoxie": "jf",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/dd/Godfather.png/180px-Godfather.png",
            "ability": "在你的首个夜晚，你会得知有哪些外来者角色在场。如果有外来者在白天死亡，你会在当晚被唤醒并且你要选择一名玩家：他死亡。[-1或+1外来者]",
            "firstNight": 5400,
            "otherNight": 8700
            },
            {
            "id": "devil's_advocate",
            "name": "魔鬼代言人",
            "pinyin": "moguidaiyanren",
            "pinyinsuoxie": "mgdyr",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/5d/Devilsadvocate.png/180px-Devilsadvocate.png",
            "ability": "每个夜晚，你要选择一名存活的玩家（与上个夜晚不同）：如果明天白天他被处决，他不会死亡。",
            "firstNight": 5500,
            "otherNight": 2600
            },
            {
            "id": "assassin",
            "name": "刺客",
            "pinyin": "cike",
            "pinyinsuoxie": "ck",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/6/69/Assassin.png/180px-Assassin.png",
            "ability": "每局游戏限一次，在夜晚时*，你可以选择一名玩家：他死亡，即使因为任何原因让他不会死亡。",
            "firstNight": 0,
            "otherNight": 8600
            },
            {
            "id": "mastermind",
            "name": "主谋",
            "pinyin": "zhumou",
            "pinyinsuoxie": "zm",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/19/Mastermind.png/180px-Mastermind.png",
            "ability": "如果恶魔因为死于处决而因此导致游戏结束时，再额外进行一个夜晚和一个白天。在那个白天如果有玩家被处决，他的阵营落败。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "evil_twin",
            "name": "镜像双子",
            "pinyin": "jingxiangshuangzi",
            "pinyinsuoxie": "jxsz",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/8e/Eviltwin.png/180px-Eviltwin.png",
            "ability": "你与一名对立阵营的玩家互相知道对方是什么角色。如果其中善良玩家被处决，邪恶阵营获胜。如果你们都存活，善良阵营无法获胜。",
            "firstNight": 5600,
            "otherNight": 0
            },
            {
            "id": "witch",
            "name": "女巫",
            "pinyin": "nvwu",
            "pinyinsuoxie": "nw",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/e6/Witch.png/180px-Witch.png",
            "ability": "每个夜晚，你要选择一名玩家：如果他明天白天发起提名，他死亡。如果只有三名存活的玩家，你失去此能力。",
            "firstNight": 5700,
            "otherNight": 2700
            },
            {
            "id": "cerenovus",
            "name": "洗脑师",
            "pinyin": "xinaoshi",
            "pinyinsuoxie": "xns",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/4d/Cerenovus.png/180px-Cerenovus.png",
            "ability": "每个夜晚，你要选择一名玩家和一个善良角色。他明天白天和夜晚需要\"疯狂\"地证明自己是这个角色，不然他可能被处决。",
            "firstNight": 5800,
            "otherNight": 2800
            },
            {
            "id": "pit-hag",
            "name": "麻脸巫婆",
            "pinyin": "malianwupo",
            "pinyinsuoxie": "mlwp",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/de/Pithag.png/180px-Pithag.png",
            "ability": "每个夜晚*，你要选择一名玩家和一个角色，如果该角色不在场，他变成该角色。如果因此创造了一个恶魔，当晚的死亡由说书人决定。",
            "firstNight": 0,
            "otherNight": 1300
            },
            {
            "id": "goblin",
            "name": "哥布林",
            "pinyin": "gebulin",
            "pinyinsuoxie": "gbl",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/d2/Goblin.png/180px-Goblin.png",
            "ability": "如果你在被提名后公开声明自己是哥布林且在那个白天被处决，你的阵营获胜。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "widow",
            "name": "寡妇",
            "pinyin": "guafu",
            "pinyinsuoxie": "gf",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/1e/Widow.png/180px-Widow.png",
            "ability": "在你的首个夜晚，你能查看魔典并选择一名玩家：他中毒。随后，始终会有一名善良玩家知道寡妇在场。",
            "firstNight": 4700,
            "otherNight": 0
            },
            {
            "id": "organ_grinder",
            "name": "街头风琴手",
            "pinyin": "jietoufengqinshou",
            "pinyinsuoxie": "jtfqs",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/f/ff/Organgrinder.png/180px-Organgrinder.png",
            "ability": "所有玩家在投票时闭眼，且票数会秘密统计。每个夜晚，你要选择自己是否醉酒直到下个黄昏。",
            "firstNight": 5410,
            "otherNight": 2520
            },
            {
            "id": "psychopath",
            "name": "精神病患者",
            "pinyin": "jingshenbinghuanzhe",
            "pinyinsuoxie": "jsbhz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/6/63/Psychopath.png/180px-Psychopath.png",
            "ability": "每个白天，在提名开始前，你可以公开选择一名玩家：他死亡。如果你被处决，提名你的玩家需要和你猜拳，只有你输了你才会死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "boffin",
            "name": "科学怪人",
            "pinyin": "kexueguairen",
            "pinyinsuoxie": "kxgr",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/f/f1/Boffin.png/180px-Boffin.png",
            "ability": "恶魔拥有一个不在场的善良角色的能力，即使他醉酒或中毒。你和他都知道他获得了什么能力。",
            "firstNight": 150,
            "otherNight": 0
            },
            {
            "id": "fearmonger",
            "name": "恐惧之灵",
            "pinyin": "kongjuzhiling",
            "pinyinsuoxie": "kjzl",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/77/Fearmonger.png/180px-Fearmonger.png",
            "ability": "每个夜晚，你要选择一名玩家：如果你提名他且他被处决，他的阵营落败。当你首次选择或更换目标时，所有玩家都会得知你选择了新的玩家。",
            "firstNight": 5900,
            "otherNight": 3000
            },
            {
            "id": "mezepheles",
            "name": "灵言师",
            "pinyin": "lingyanshi",
            "pinyinsuoxie": "lys",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/19/Mezepheles.png/180px-Mezepheles.png",
            "ability": "在你的首个夜晚，你会得知一个关键词。首个说出该关键词的善良玩家会在当晚转变为邪恶阵营。",
            "firstNight": 6100,
            "otherNight": 3200
            },
            {
            "id": "marionette",
            "name": "提线木偶",
            "pinyin": "tixianmuou",
            "pinyinsuoxie": "txmo",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/3d/Marionette.png/180px-Marionette.png",
            "ability": "你以为你是一个善良角色，但其实你不是。恶魔会知道你是提线木偶。[提线木偶会与恶魔邻座]",
            "firstNight": 3200,
            "otherNight": 0
            },
            {
            "id": "vizier",
            "name": "维齐尔",
            "pinyin": "weiqier",
            "pinyinsuoxie": "wqe",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/09/Vizier.png/180px-Vizier.png",
            "ability": "所有玩家都知道你是维齐尔。你在白天时不会死亡。如果一次提名中有善良玩家投票，你可以让被提名者立即被处决。",
            "firstNight": 12900,
            "otherNight": 0
            },
            {
            "id": "wizard",
            "name": "巫师",
            "pinyin": "wushi",
            "pinyinsuoxie": "ws",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c7/Wizard.png/180px-Wizard.png",
            "ability": "每局游戏限一次，你可以向说书人许愿。如果愿望被实现，可能会伴随着代价和线索。",
            "firstNight": 5150,
            "otherNight": 1950
            },
            {
            "id": "xaan",
            "name": "限",
            "pinyin": "xian",
            "pinyinsuoxie": "x",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/b9/Xaan.png/180px-Xaan.png",
            "ability": "在等同于初始外来者数量的夜晚，所有镇民玩家中毒直到下个黄昏。[外来者数量任意]",
            "firstNight": 4575,
            "otherNight": 1350
            },
            {
            "id": "harpy",
            "name": "鹰身女妖",
            "pinyin": "yingshennvyao",
            "pinyinsuoxie": "ysny",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/1b/Harpy.png/180px-Harpy.png",
            "ability": "每个夜晚，你要选择两名玩家：明天第一名玩家需要\"疯狂\"地证明第二名玩家是邪恶的，否则他们之中可能会有人死亡。",
            "firstNight": 6000,
            "otherNight": 3100
            },
            {
            "id": "boomdandy",
            "name": "炸弹人",
            "pinyin": "zhadanren",
            "pinyinsuoxie": "zdr",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/b0/Boomdandy.png/180px-Boomdandy.png",
            "ability": "如果你被处决，除三名玩家以外的其他所有玩家均会死亡。倒数十声后，被最多玩家手指指着的玩家死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "summoner",
            "name": "召唤师",
            "pinyin": "zhaohuanshi",
            "pinyinsuoxie": "zhs",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/2/2f/Summoner.png/180px-Summoner.png",
            "ability": "在首个夜晚，你会得知三个伪装。在第三个夜晚，你要选择一名玩家：他变成由你选择的邪恶恶魔。[无恶魔在场]",
            "firstNight": 2210,
            "otherNight": 3710
            },
            {
            "id": "ganshiren",
            "name": "赶尸人",
            "pinyin": "ganshiren",
            "pinyinsuoxie": "gsr",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/7f/Ganshiren.png/180px-Ganshiren.png",
            "ability": "与你邻近的两名镇民玩家会在其首次死亡时被当作仍然存活。[-1外来者]",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "humeiniang",
            "name": "狐媚娘",
            "pinyin": "humeiniang",
            "pinyinsuoxie": "hmn",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/9/94/Humeiniang.png/180px-Humeiniang.png",
            "ability": "在你的首个夜晚，你要选择一名玩家：他会知道狐媚娘在场。如果你死于处决，当晚他转变为邪恶阵营。",
            "firstNight": 6200,
            "otherNight": 3300
            },
            {
            "id": "yangguren",
            "name": "养蛊人",
            "pinyin": "yangguren",
            "pinyinsuoxie": "ygr",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/80/Yangguren.png/180px-Yangguren.png",
            "ability": "在你存活时提名你的玩家会在当晚死亡，即使你已死亡。",
            "firstNight": 0,
            "otherNight": 8800
            },
            {
            "id": "gudiao",
            "name": "蛊雕",
            "pinyin": "gudiao",
            "pinyinsuoxie": "gd",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/56/Gudiao.png/180px-Gudiao.png",
            "ability": "每个夜晚，你要选择左或右：你得知该方向上的下一名存活善良玩家的角色，他中毒且其他善良玩家以为他是邪恶的蛊雕，直到下个黄昏。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "huapi",
            "name": "画皮",
            "pinyin": "huapi",
            "pinyinsuoxie": "hp",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/59/Huapi.png/180px-Huapi.png",
            "ability": "在你的首个夜晚，你要选择一名存活玩家：他死亡但会被当作存活。当他下一次即将死亡时，他重生，随后你重获能力。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "mengpo",
            "name": "孟婆",
            "pinyin": "mengpo",
            "pinyinsuoxie": "mp",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/e4/Mengpo.png/180px-Mengpo.png",
            "ability": "每个夜晚*，你要选择一名玩家：如果他存活，那么他要选择让自己失去能力，或死亡并保留能力直到下个黄昏。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "niangjiushi",
            "name": "酿酒师",
            "pinyin": "niangjiushi",
            "pinyinsuoxie": "nj",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/e/ea/Niangjiushi.png/180px-Niangjiushi.png",
            "ability": "每个夜晚，你要选择一个镇民角色：当他下一次通过自身能力获取信息时，改为得知你给出的信息。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "oldpit-hag",
            "name": "旧麻脸巫婆",
            "pinyin": "jiumalianwupo",
            "pinyinsuoxie": "jmlwp",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/d/de/Pithag.png/180px-Pithag.png",
            "ability": "",
            "firstNight": 0,
            "otherNight": 2900
            },
            {
            "id": "oldharpy",
            "name": "旧鹰身女妖",
            "pinyin": "jiuyingshennvyao",
            "pinyinsuoxie": "jysny",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/1b/Harpy.png/180px-Harpy.png",
            "ability": "",
            "firstNight": 6010,
            "otherNight": 3110
            },
            {
            "id": "oldorgan_grinder",
            "name": "旧街头风琴手",
            "pinyin": "jiujietoufengqinshou",
            "pinyinsuoxie": "jjtfqs",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/f/ff/Organgrinder.png/180px-Organgrinder.png",
            "ability": "",
            "firstNight": 5420,
            "otherNight": 2530
            },
            {
            "id": "oldboomdandy",
            "name": "旧炸弹人",
            "pinyin": "jiuzhadanren",
            "pinyinsuoxie": "jzdr",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/b0/Boomdandy.png/180px-Boomdandy.png",
            "ability": "",
            "firstNight": 0,
            "otherNight": 0
            }
    ]


        const demonsRoles = [
        {
            "id": "imp",
            "name": "小恶魔",
            "pinyin": "xiaoemo",
            "pinyinsuoxie": "xem",
            "scripts": ["暗流涌动"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/b3/Imp.png/180px-Imp.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。如果你以这种方式自杀，一名爪牙会变成小恶魔。",
            "firstNight": 0,
            "otherNight": 4900
        },
        {
            "id": "zombuul",
            "name": "僵怖",
            "pinyin": "jiangbu",
            "pinyinsuoxie": "jb",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/7b/Zombuul.png/180px-Zombuul.png",
            "ability": "每个夜晚*，如果今天白天没有人死亡，你会被唤醒并要选择一名玩家：他死亡。当你首次死亡后，你仍存活，但会被当作死亡。",
            "firstNight": 0,
            "otherNight": 5000
        },
        {
            "id": "pukka",
            "name": "普卡",
            "pinyin": "puka",
            "pinyinsuoxie": "pk",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/45/Pukka.png/180px-Pukka.png",
            "ability": "每个夜晚，你要选择一名玩家：他中毒。上个因你的能力中毒的玩家会死亡并恢复健康。",
            "firstNight": 6600,
            "otherNight": 5100
        },
        {
            "id": "shabaloth",
            "name": "沙巴洛斯",
            "pinyin": "shabaluosi",
            "pinyinsuoxie": "sbls",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/5c/Shabaloth.png/180px-Shabaloth.png",
            "ability": "每个夜晚*，你要选择两名玩家：他们死亡。你上个夜晚选择过且当前死亡的玩家之一可能会被你反刍。",
            "firstNight": 0,
            "otherNight": 5200
        },
        {
            "id": "po",
            "name": "珀",
            "pinyin": "po",
            "pinyinsuoxie": "p",
            "scripts": ["黯月初升"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/b/bf/Po.png/180px-Po.png",
            "ability": "每个夜晚*，你可以选择一名玩家：他死亡。如果你上次选择时没有选择任何玩家，当晚你要选择三名玩家：他们死亡。",
            "firstNight": 0,
            "otherNight": 5300
        },
        {
            "id": "fang_gu",
            "name": "方古",
            "pinyin": "fanggu",
            "pinyinsuoxie": "fg",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/9/97/Fanggu.png/180px-Fanggu.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。被该能力杀死的外来者改为变成邪恶的方古且你代替他死亡，但每局游戏仅能成功转化一次。[+1外来者]",
            "firstNight": 0,
            "otherNight": 5400
        },
        {
            "id": "vigormortis",
            "name": "亡骨魔",
            "pinyin": "wanggumo",
            "pinyinsuoxie": "wgm",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/f/fc/Vigormortis.png/180px-Vigormortis.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。被你杀死的爪牙保留他的能力，且与他邻近的两名镇民之一中毒。[-1外来者]",
            "firstNight": 0,
            "otherNight": 6100
        },
        {
            "id": "no_dashii",
            "name": "诺-达鲺",
            "pinyin": "nuodashi",
            "pinyinsuoxie": "nds",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/16/Nodashii.png/180px-Nodashii.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。与你邻近的两名镇民中毒。",
            "firstNight": 0,
            "otherNight": 5500
        },
        {
            "id": "vortox",
            "name": "涡流",
            "pinyin": "woliu",
            "pinyinsuoxie": "wl",
            "scripts": ["梦殒春宵"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/78/Vortox.png/180px-Vortox.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。镇民玩家的能力都会产生错误信息。如果白天没人被处决，邪恶阵营获胜。",
            "firstNight": 0,
            "otherNight": 5600
        },
        {
            "id": "ojo",
            "name": "奥赫",
            "pinyin": "aohe",
            "pinyinsuoxie": "ah",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/9/96/Ojo.png/180px-Ojo.png",
            "ability": "每个夜晚*，你要选择一个角色：他死亡。如果该角色不在场，则由说书人来决定谁会被你杀死。",
            "firstNight": 0,
            "otherNight": 6200
        },
        {
            "id": "riot",
            "name": "暴乱",
            "pinyin": "baoluan",
            "pinyinsuoxie": "bl",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c0/Riot.png/180px-Riot.png",
            "ability": "在第三个白天，所有爪牙会变成暴乱，当天被提名的玩家会立即死亡且必须再次提名一名存活的玩家。",
            "firstNight": 0,
            "otherNight": 0
        },
        {
            "id": "lord_of_typhon",
            "name": "堤丰之首",
            "pinyin": "difengzhishou",
            "pinyinsuoxie": "dfzs",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/18/Lordoftyphon.png/180px-Lordoftyphon.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。[邪恶角色全部邻座，你靠近正中，+1爪牙，-或+任意数量外来者]",
            "firstNight": 140,
            "otherNight": 5700
            },
            {
            "id": "al-hadikhia",
            "name": "哈迪寂亚",
            "pinyin": "hadijiya",
            "pinyinsuoxie": "hdjy",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/09/Alhadikhia.png/180px-Alhadikhia.png",
            "ability": "每个夜晚*，你可以选择三名玩家（所有玩家都会得知你选了谁）：他们分别秘密决定自己的生死，然后如果他们都存活则都死亡。",
            "firstNight": 0,
            "otherNight": 7000
            },
            {
            "id": "legion",
            "name": "军团",
            "pinyin": "juntuan",
            "pinyinsuoxie": "jt",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/2/25/Legion.png/180px-Legion.png",
            "ability": "每个夜晚*，可能有一名玩家死亡。如果一项提名只有邪恶玩家投票，投票无效。你也会被当作是爪牙。[多数玩家为军团]",
            "firstNight": 0,
            "otherNight": 6000
            },
            {
            "id": "kazali",
            "name": "卡扎力",
            "pinyin": "kazhali",
            "pinyinsuoxie": "kzl",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/46/Kazali.png/180px-Kazali.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。[由你决定谁是什么爪牙，-或+任意数量外来者]",
            "firstNight": 1000,
            "otherNight": 7700
            },
            {
            "id": "leviathan",
            "name": "利维坦",
            "pinyin": "liweitan",
            "pinyinsuoxie": "lwt",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/0a/Leviathan.png/180px-Leviathan.png",
            "ability": "如果多于一名善良玩家被处决，邪恶阵营获胜。所有玩家都知道利维坦在场。在第五个白天结束时，邪恶阵营获胜。",
            "firstNight": 12800,
            "otherNight": 15100
            },
            {
            "id": "lleech",
            "name": "痢蛭",
            "pinyin": "lizhi",
            "pinyinsuoxie": "lz",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/70/Lleech.png/180px-Lleech.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。在你的首个夜晚，你要选择一名存活的玩家：他中毒，只有当他处于死亡状态时你才会立即死亡。",
            "firstNight": 4500,
            "otherNight": 7200
            },
            {
            "id": "lil_monsta",
            "name": "小怪宝",
            "pinyin": "xiaoguaibao",
            "pinyinsuoxie": "xgb",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/39/Lilmonsta.png/180px-Lilmonsta.png",
            "ability": "每个夜晚，所有爪牙要秘密决定由哪名玩家来照看小怪宝并且\"是恶魔\"。每个夜晚*，可能会有一名玩家死亡。[+1爪牙]",
            "firstNight": 4400,
            "otherNight": 7300
            },
            {
            "id": "yaggababble",
            "name": "牙噶巴卜",
            "pinyin": "yagababu",
            "pinyinsuoxie": "ygbb",
            "scripts": ["实验性角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/50/Yaggababble.png/180px-Yaggababble.png",
            "ability": "在你的首个夜晚，你会得知一段秘密短语。每次你在白天公开说出这段短语，当天便可能会有一名玩家在这之后死亡。",
            "firstNight": 6610,
            "otherNight": 7400
            },
            {
            "id": "hundun",
            "name": "混沌",
            "pinyin": "hundun",
            "pinyinsuoxie": "hd",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/4/49/Hundun.png/180px-Hundun.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。如果你以这种方式杀死了一名与你邻近的镇民玩家，除旅行者外的所有善良玩家会中毒直到下个黄昏。",
            "firstNight": 0,
            "otherNight": 7900
            },
            {
            "id": "qiongqi",
            "name": "穷奇",
            "pinyin": "qiongqi",
            "pinyinsuoxie": "qq",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/1/13/Qiongqi.png/180px-Qiongqi.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。如果今天白天有外来者死亡，当晚改为你要选择一名玩家：他死亡，但被当作仍然存活，随后会有一名其他玩家死亡。[+1外来者]",
            "firstNight": 0,
            "otherNight": 8000
            },
            {
            "id": "taotie",
            "name": "饕餮",
            "pinyin": "taotie",
            "pinyinsuoxie": "tt",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/8/85/Taotie.png/180px-Taotie.png",
            "ability": "每个夜晚*，你要选择任意数量的非旅行者玩家或一名旅行者玩家：如果他们的角色类型均不相同，他们死亡。[+1外来者]",
            "firstNight": 0,
            "otherNight": 8100
            },
            {
            "id": "taowu",
            "name": "梼杌",
            "pinyin": "taowu",
            "pinyinsuoxie": "tw",
            "scripts": ["华灯初上"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/5/52/Taowu.png/180px-Taowu.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。当你将要死亡时，改为一名存活且具有能力的爪牙失去能力。你不会得知恶魔信息。",
            "firstNight": 2800,
            "otherNight": 8200
            },
            {
            "id": "baojun",
            "name": "暴君",
            "pinyin": "baojun",
            "pinyinsuoxie": "bj",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c5/Baojun.png/180px-Baojun.png",
            "ability": "每个夜晚*，你可以选择至多两名玩家：他们死亡。你选择的玩家数量不能与上个夜晚死亡的玩家数量相同（超过二人时算作二人）。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "dianyuzhang",
            "name": "典狱长",
            "pinyin": "dianyuzhang",
            "pinyinsuoxie": "dyz",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c5/Baojun.png/180px-Baojun.png",
            "ability": "每个夜晚，你要选择至多三名玩家：如果明天白天他们之一死于处决，上次被你选择的其他玩家会在当晚死亡。否则，当晚他们之中会有一名玩家死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "guhuoniao",
            "name": "姑获鸟",
            "pinyin": "guhuoniao",
            "pinyinsuoxie": "ghn",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/38/Guhuoniao.png/180px-Guhuoniao.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。你可能会拥有上一个死于处决的爪牙的能力。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "jianning",
            "name": "奸佞",
            "pinyin": "jianning",
            "pinyinsuoxie": "jn",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/3a/Jianning.png/180px-Jianning.png",
            "ability": "每个夜晚*，你要选择一名玩家：他死亡。如果你今天白天没有投票，今晚你可以行动两次。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "yanluo",
            "name": "阎罗",
            "pinyin": "yanluo",
            "pinyinsuoxie": "yl",
            "scripts": ["山雨欲来"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c8/Yanluo.png/180px-Yanluo.png",
            "ability": "在你的首个夜晚，你能查看魔典并选择一名玩家：他在第三个夜晚死亡，即使因为任何原因让他不会死亡。每个夜晚，你要选择一名玩家：上个夜晚被你选择的玩家死亡。",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "oldlil_monsta",
            "name": "旧小怪宝",
            "pinyin": "jiuxiaoguaibao",
            "pinyinsuoxie": "jxgb",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/3/39/Lilmonsta.png/180px-Lilmonsta.png",
            "ability": "",
            "firstNight": 4410,
            "otherNight": 7310
            },
            {
            "id": "oldlleech",
            "name": "旧痢蛭",
            "pinyin": "jiulizhi",
            "pinyinsuoxie": "jlz",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/7/70/Lleech.png/180px-Lleech.png",
            "ability": "",
            "firstNight": 4510,
            "otherNight": 7210
            },
            {
            "id": "oldriot",
            "name": "旧暴乱",
            "pinyin": "jiubaoluan",
            "pinyinsuoxie": "jbl",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/c/c0/Riot.png/180px-Riot.png",
            "ability": "",
            "firstNight": 0,
            "otherNight": 0
            },
            {
            "id": "oldal-hadikhia",
            "name": "旧哈迪寂亚",
            "pinyin": "jiuhadijiya",
            "pinyinsuoxie": "jhdjy",
            "scripts": ["旧版角色"],
            "image": "https://clocktower-wiki.gstonegames.com/images/thumb/0/09/Alhadikhia.png/180px-Alhadikhia.png",
            "ability": "",
            "firstNight": 0,
            "otherNight": 7010
            }
        ]


        // 旅行者（从 @剧本JSON 中常见字段抽象，先提供空数组，后续可增）
        const travelersRoles = [
        {"id":"bundagee_trav_binji","name":"宾鸡","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/bigyellowfish/Bundagee_Inn_Massacre_Bigyellowfish/25_bundagee_inn_massacre_bigyellowfish.png","ability":"每个夜晚，你要选择一名玩家：他当晚不会因其自身能力而被唤醒。如果他在下个白天没有投票，再下个白天他的投票算作三票。","firstNight":13,"otherNight":5},
        {"id":"bundagee_trav_lajifenlei","name":"垃圾分类员","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/bigyellowfish/Bundagee_Inn_Massacre_Bigyellowfish/26_bundagee_inn_massacre_bigyellowfish.png","ability":"每个夜晚，你要选择三名玩家：如果他们都是同一阵营，下个白天，他们参与投票的处决会失败。","firstNight":12,"otherNight":3},
        {"id":"bundagee_trav_toumingren","name":"透明人","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/bigyellowfish/Bundagee_Inn_Massacre_Bigyellowfish/27_bundagee_inn_massacre_bigyellowfish.png","ability":"每个夜晚，你要选择两名玩家：他们的能力额外行动一次，且这次行动以对方为目标。","firstNight":11,"otherNight":2},
        {"id":"bundagee_trav_banqiu","name":"板球运动员","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/bigyellowfish/Bundagee_Inn_Massacre_Bigyellowfish/28_bundagee_inn_massacre_bigyellowfish.png","ability":"如果从游戏开始到现在正好有善良玩家发起过六次提名，此时你公开声明使用能力，则你的阵营的玩家在今天白天和夜晚不会死亡。","firstNight":0,"otherNight":0},
        {"id":"bundagee_trav_diangong","name":"电工","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/bigyellowfish/Bundagee_Inn_Massacre_Bigyellowfish/29_bundagee_inn_massacre_bigyellowfish.png","ability":"所有玩家在投票时闭眼，且票数会秘密统计。","firstNight":0,"otherNight":0},
        {"id":"emotions_depression","name":"抑郁","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/Moll_of_Power/Emotions/depression_emotions.png","ability":"每个夜晚*，你要选择除你以外从未选择过的一名玩家：他会得知你的阵营。如果你被流放，你转变为对立阵营。","firstNight":0,"otherNight":1},
        {"id":"apprentice_meet","name":"学徒","scripts":["全原创角色"],"image":"https://oss.gstonegames.com/data_file/clocktower/web/icons/apprentice.png","ability":"在你的首个夜晚，如果你是善良的，你会获得一个镇民角色的能力；如果你是邪恶的，你会获得一个爪牙角色的能力。","firstNight":1,"otherNight":0},
        {"id":"liudongshangfan","name":"流动商贩","scripts":["全原创角色"],"image":"https://i.postimg.cc/V6hrxshG/image.png","ability":"每个夜晚，你要和一名除你以外的存活玩家交换座位，然后如果与你邻近的两名存活玩家的阵营不同，你转变阵营。","firstNight":1,"otherNight":1},
        {"id":"daybyday_coupcaller","name":"政变召集员","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/Imzecorella/Day_By_Day/coupcaller_day_by_day.png","ability":"当一名玩家被提名时，你可以公开发表一个声明。每局游戏限一次，如果该声明正确且那名玩家被处决，他不会死亡。","firstNight":0,"otherNight":0},
        {"id":"daybyday_secretary","name":"秘书","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/Imzecorella/Day_By_Day/secretary_day_by_day.png","ability":"每局游戏限一次，在夜晚时，你可以选择一名玩家：他的能力会转变为相同角色类型的一个其他角色，直到你死亡或离开游戏。","firstNight":13,"otherNight":3},
        {"id":"daybyday_paramour","name":"情人","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/Imzecorella/Day_By_Day/paramour_day_by_day.png","ability":"每个黎明，一名死亡的玩家会重新获得投票标记。如果你是邪恶的，你要在上个夜晚选择一名死亡玩家以获得投票标记。","firstNight":0,"otherNight":5},
        {"id":"daybyday_catfan","name":"爱猫狂热人士","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/Imzecorella/Day_By_Day/fanatic_day_by_day.png","ability":"每个夜晚*，如果你在今天白天“疯狂”地证明除你以外的所有玩家都是猫，你会得知两件事情，你要选择其中一件发生，所有玩家都会得知你的选择。","firstNight":0,"otherNight":2},
        {"id":"daybyday_framer","name":"筹划者","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/Imzecorella/Day_By_Day/framer_day_by_day.png","ability":"每个夜晚，你要选择一名存活的玩家：你可能与他交换角色。初始的筹划者随时可以与你交换角色并离开游戏，即使你已死亡。","firstNight":14,"otherNight":4},
        {"id":"cooldoom_timewalker","name":"时空行者","scripts":["全原创角色"],"image":"https://www.bloodstar.xyz/p/papel/YZ_CN_GGG/24_yz_cn_ggg.png","ability":"每局游戏限一次，你随时可以禁止私聊。每局游戏限一次，你可以在一次提名发起后禁止之后的游戏中再发起提名。","firstNight":0,"otherNight":0}
        ]

        // 传奇角色（从 @剧本JSON 中常见字段抽象，先提供空数组，后续可增）
        const fabledRoles = [
        {"id":"seve_baiduren","name":"摆渡人","scripts":["BWG·剧本大乱斗"],"image":"https://www.bloodstar.xyz/p/Guiltier/seve/26_seve.png","ability":"在游戏的最后一天，所有已死亡玩家会重新获得投票标记。","firstNight":0,"otherNight":0},
        {"id":"seve_bukesiyi","name":"不可思议","scripts":["BWG·剧本大乱斗"],"image":"https://www.bloodstar.xyz/p/Guiltier/seve/_seve.png","ability":"初始无爪牙在场。所有玩家都知道议是谁，且议不会醉酒、中毒、死亡。死亡的邪恶玩家数量等于初始配置时，善良阵营获胜。","firstNight":0,"otherNight":0}
        ,{"id":"night_sihuoshangren","name":"私货商人","scripts":["BWG·剧本大乱斗"],"image":"https://clocktower-wiki.gstonegames.com/images/thumb/9/97/Bootlegger.png/300px-Bootlegger.png","ability":"镇民都是守夜人，科学怪人只会给恶魔守夜人的能力。","firstNight":0,"otherNight":0}
        ]


        const legacyRolesJson = [
            {"id":"oldking",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/1/1d/King.png/300px-King.png",
                "edition":"custom",
                "name":"旧国王",
                "ability":"每个夜晚，如果死亡的玩家数量大于存活的玩家数量，你会得知一个存活的角色。恶魔知道你是国王。",
                "team":"townsfolk",
                "sch_team":"镇民",
                "firstNight":3110,
                "otherNight":13110,
                "firstNightReminder":"唤醒恶魔，并告诉他国王是谁。",
                "otherNightReminder":"如果死亡玩家人数大于存活玩家，唤醒国王并对其展示一个存活的角色标记。"},

            {"id":"oldlil_monsta",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/3/39/Lilmonsta.png/300px-Lilmonsta.png",
                "edition":"custom",
                "name":"旧小怪宝",
                "ability":"每个夜晚，所有爪牙要秘密决定由哪名玩家来照看小怪宝并且\\\"是恶魔\\\"。每个夜晚*，会有一名玩家死亡。[+1爪牙]",
                "team":"demon",
                "sch_team":"恶魔",
                "firstNight":4410,
                "otherNight":7310,
                "firstNightReminder":"唤醒所有爪牙，允许他们以指向的方式决定谁照看小怪宝，但不能产生其他交流，否则会有非常糟糕的事情发生。",
                "otherNightReminder":"唤醒所有爪牙，允许他们以指向的方式决定谁照看小怪宝，但不能产生其他交流，否则会有非常糟糕的事情发生。说书人选择一名玩家，那名玩家死亡。",
                "reminders":[],
                "remindersGlobal":["是恶魔","死亡"],
                "setup":true},
            
            {"id":"oldballoonist",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/3/35/Balloonist.png/300px-Balloonist.png",
                "edition":"custom",
                "name":"旧气球驾驶员",
                "ability":"每个夜晚，你会得知一名不同角色类型的玩家，直到场上所有的角色类型你都得知过一次。[+1 外来者]",
                "team":"townsfolk",
                "sch_team":"镇民",
                "firstNight":9110,
                "otherNight":12110,
                "firstNightReminder":"选择一种角色类型，并告知其一个符合该类型的玩家。在该玩家旁边标记已被知晓。",
                "otherNightReminder":"选择一种尚未被气球驾驶员知晓的角色类型，并告知其一个符合该类型的玩家。在该玩家旁边标记已被知晓。如果所有类型均已被知晓或无该种类型，气球驾驶员不会醒来。",
                "reminders":["得知镇民","得知外来者","得知爪牙","得知恶魔","得知旅行者"],
                "setup":true},

            {"id":"oldplague_doctor",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/2/2d/Plaguedoctor.png/200px-Plaguedoctor.png",
                "edition":"custom",
                "name":"旧瘟疫医生",
                "ability":"如果你死亡，说书人获得一个不在场的爪牙能力。",
                "team":"outsider",
                "sch_team":"外来者",
                "firstNight":0,
                "otherNight":10010,
                "reminders":["说书人能力"]},

            {"id":"oldharpy",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/1/1b/Harpy.png/200px-Harpy.png",
                "edition":"custom",
                "name":"旧鹰身女妖",
                "ability":"每个夜晚，你要选择两名玩家：明天第一名玩家需要\"疯狂\"地证明第二名玩家是邪恶的，否则他们可能会死亡。",
                "team":"minion",
                "sch_team":"爪牙",
                "firstNight":6010,
                "otherNight":3110,
                "reminders":["疯狂","第二名"],
                "setup":false},

            {"id":"oldlleech",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/7/70/Lleech.png/300px-Lleech.png",
                "edition":"custom",
                "name":"旧痢蛭",
                "ability":"每个夜晚*，你要选择一名玩家：他死亡。在你的首个夜晚，你要选择一名存活的玩家：他中毒，只有他死亡时你才会一同死亡。",
                "team":"demon",
                "sch_team":"恶魔",
                "firstNight":4510,
                "otherNight":7210,
                "firstNightReminder":"痢蛭指向一名玩家。放置寄生标记，那名玩家中毒。",
                "otherNightReminder":"寄生蛭指向一名玩家。那名玩家死亡。",
                "reminders":["死亡","中毒"],
                "setup":false},

            {"id":"oldorgan_grinder",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/f/ff/Organgrinder.png/300px-Organgrinder.png",
                "edition":"custom",
                "name":"旧街头风琴手",
                "ability":"所有玩家在投票时闭眼，且票数会秘密统计。对你的提名只在你投票时才会统计票数。",
                "team":"minion",
                "sch_team":"爪牙",
                "firstNight":0,
                "otherNight":0,
                "reminders":["即将被处决"]},

            {"id":"oldacrobat",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/8/8f/Acrobat.png/300px-Acrobat.png",
                "edition":"custom",
                "name":"旧杂技演员",
                "ability":"每个夜晚*，如果与你邻近的存活善良玩家之一醉酒或中毒，你死亡。",
                "team":"outsider",
                "sch_team":"外来者",
                "firstNight":0,
                "otherNight":8910,
                "otherNightReminder":"如果杂技演员左右两侧最近的存活善良玩家之一中毒或醉酒，杂技演员死亡。",
                "reminders":["死亡"]},                

            {"id":"oldfarmer",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/3/3d/Farmer.png/300px-Farmer.png",
                "edition":"custom",
                "name":"旧农夫",
                "ability":"如果你在夜晚死亡，一名存活的善良玩家会变成农夫。",
                "team":"townsfolk",
                "sch_team":"镇民",
                "firstNight":0,
                "otherNight":10310,
                "firstNightReminder":"",
                "otherNightReminder":"如果农民在夜晚死去，则选择另一位善良玩家成为农民。唤醒这名玩家，并告知他成为了农民。",
                "reminders":[],
                "setup":false},
            
            {
                "id": "oldalsaahir",
                "image": "https://clocktower-wiki.gstonegames.com/images/d/d6/Alsaahir.png",
                "edition": "custom",
                "name": "旧戏法师",
                "ability": "每个白天限一次，你可以公开猜测谁是爪牙，谁是恶魔。如果你猜对，善良阵营获胜",
                "team": "townsfolk",
                "sch_team": "镇民",
                "firstNight":0,
                "otherNight":0,
                "firstNightReminder": "",
                "otherNightReminder": "",
                "reminders": [],
                "setup": false
            },

            {"id":"oldboomdandy",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/b/b0/Boomdandy.png/300px-Boomdandy.png",
                "edition":"custom",
                "name":"旧炸弹人",
                "ability":"如果你被处决，除三名玩家以外的其他所有玩家均会死亡。一分钟之后，被最多玩家手指指着的玩家死亡。",
                "team":"minion",
                "sch_team":"爪牙",
                "firstNight":0,
                "otherNight":0,
                "firstNightReminder":"",
                "otherNightReminder":"",
                "reminders":[],
                "setup":false},

            {"id":"oldlycanthrope",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/c/c1/Lycanthrope.png/300px-Lycanthrope.png",
                "edition":"custom",
                "name":"旧半兽人",
                "ability":"每个夜晚*，你要选择一名存活的玩家，如果他是善良的，他死亡，并且当晚不会再有其他玩家死亡。",
                "team":"townsfolk",
                "sch_team":"镇民",
                "firstNight":0,
                "otherNight":4410,
                "otherNightReminder":"半兽人指向一名存活玩家：如果那名玩家善良，则立刻死去且今夜不会再有玩家死亡。",
                "reminders":["死亡"]},

            {"id":"oldriot",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/c/c0/Riot.png/300px-Riot.png",
                "edition":"custom",
                "name":"旧暴乱",
                "ability":"被提名的玩家死亡，但他可以立刻再次发起提名（第三天白天他必须这么做）。在第三个白天结束时，邪恶阵营获胜。[所有爪牙都是暴乱]",
                "team":"demon",
                "sch_team":"恶魔",
                "firstNight":0,
                "otherNight":0,
                "firstNightReminder":"",
                "otherNightReminder":"",
                "reminders":[],
                "setup":true},

            {"id":"oldalchemist",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/5/5b/Alchemist.png/300px-Alchemist.png",
                "edition":"custom",
                "name":"旧炼金术士",
                "ability":"你拥有一个不在场的爪牙角色的能力。",
                "team":"townsfolk",
                "sch_team":"镇民",
                "firstNight":610,
                "otherNight":0,
                "firstNightReminder":"向炼金术士展示一个不在场爪牙的角色标记。",
                "remindersGlobal":["是炼金术士"]},

            {"id":"oldal-hadikhia",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/0/09/Alhadikhia.png/300px-Alhadikhia.png",
                "edition":"custom",
                "name":"旧哈迪寂亚",
                "ability":"每个夜晚*，你要选择三名玩家（所有玩家会得知你选了谁）：他们分别秘密决定自己的生死，然后如果他们都存活则都死亡。",
                "team":"demon",
                "sch_team":"恶魔",
                "firstNight":0,
                "otherNight":7010,
                "firstNightReminder":"",
                "otherNightReminder":"哈迪寂亚选择三名玩家。对所有人宣告第一位玩家，然后唤醒他并让他秘密选择活着还是死去。依次对第二第三位玩家如此做。如果三名玩家都选择活着，他们都死去。",
                "reminders":["1","2","3","选择生","选择死"],
                "setup":false},

            {"id":"oldpit-hag",
                "image":"https://clocktower-wiki.gstonegames.com/images/thumb/d/de/Pithag.png/300px-Pithag.png",
                "edition":"custom",
                "name":"旧麻脸巫婆",
                "ability":"每个夜晚*，你要选择一名玩家和一个角色，如果该角色不在场，他变成该角色。如果因此创造了一个恶魔，当晚的死亡由说书人决定。",
                "team":"minion",
                "sch_team":"爪牙",
                "firstNight":0,
                "otherNight":2910,
                "firstNightReminder":"",
                "otherNightReminder":"让麻脸巫婆选择一名玩家和一个角色。如果她选择的角色不在场：让麻脸巫婆重新入睡。唤醒她的目标玩家。对该玩家展示\"你是\"信息标记和他的新角色标记。",
                "reminders":[],
                "setup":false}
        ];



        function populateNightRefSelects() {
            // 收集所有角色的firstNight信息
            const allRoles = [...townsfolkRoles, ...outsidersRoles, ...minionsRoles, ...demonsRoles];
            const nightRefs = [];
            
            allRoles.forEach(role => {
                if (role.firstNight && role.firstNight > 0) {
                    nightRefs.push({
                        name: role.name,
                        value: role.firstNight
                    });
                }
            });
            
            // 按firstNight值从小到大排序
            nightRefs.sort((a, b) => a.value - b.value);
            
            // 填充firstNightRef下拉框
            const firstNightRefSelect = document.getElementById('firstNightRef');
            nightRefs.forEach(ref => {
                const option = document.createElement('option');
                option.value = ref.value;
                option.textContent = `${ref.value} - ${ref.name}`;
                firstNightRefSelect.appendChild(option);
            });
        
            // 处理otherNight
            const otherNightRefs = [];
            
            allRoles.forEach(role => {
                if (role.otherNight && role.otherNight > 0) {
                    otherNightRefs.push({
                        name: role.name,
                        value: role.otherNight
                    });
                }
            });
            
            // 按otherNight值从小到大排序
            otherNightRefs.sort((a, b) => a.value - b.value);
            
            // 填充otherNightRef下拉框
            const otherNightRefSelect = document.getElementById('otherNightRef');
            otherNightRefs.forEach(ref => {
                const option = document.createElement('option');
                option.value = ref.value;
                option.textContent = `${ref.value} - ${ref.name}`;
                otherNightRefSelect.appendChild(option);
            });
        }


        // 在页面加载完成后调用
        window.addEventListener('DOMContentLoaded', populateNightRefSelects);


        const searchResults = document.getElementById('search-results');
        const searchInput = document.getElementById('search-role-input');

        searchInput.addEventListener('input', function() {
            const query = this.value.trim().toLowerCase();
            if (query === '') {
                searchResults.style.display = 'none';
                return;
            }

            const allRoles = [...townsfolkRoles, ...outsidersRoles, ...minionsRoles, ...demonsRoles];
            const matchingRoles = allRoles.filter(role => {
                //const id = role.id.toLowerCase();
                const name = role.name.toLowerCase();
                //const pinyin = role.pinyin.toLowerCase();
                const pinyinsuoxie = role.pinyinsuoxie.toLowerCase();
                
                //return id.includes(query) || 
                return name.includes(query) || 
                    //pinyin.includes(query) || 
                    pinyinsuoxie.includes(query);
            });

            searchResults.innerHTML = '';
            if (matchingRoles.length > 0) {
                searchResults.style.display = 'block';
                matchingRoles.forEach(role => {
                    const resultItem = document.createElement('div');
                    resultItem.textContent = role.name;
                    resultItem.addEventListener('click', function() {
                        const checkbox = document.querySelector(`.role-item input[value="${role.id}"]`);
                        if (checkbox) {
                            checkbox.checked = true;
                            updateSelectionCount();
                        }
                        searchResults.style.display = 'none';
                        searchInput.value = '';
                    });
                    searchResults.appendChild(resultItem);
                });
            } else {
                searchResults.style.display = 'none';
            }
        });

        // 当点击页面其他地方时隐藏搜索结果
        document.addEventListener('click', function(event) {
            if (event.target !== searchInput) {
                searchResults.style.display = 'none';
            }
        });

        // 根据角色对象解析图片链接（优先使用提供的image，其次按id构造，再使用占位图）
        function resolveRoleImage(role) {
            if (role && role.image) {
                return role.image;
            }
            if (role && role.id) {
                return `https://clocktower-wiki.gstonegames.com/images/thumb/0/0a/${role.id}.png/180px-${role.id}.png`;
            }
            return 'https://clocktower-wiki.gstonegames.com/skins/pivot/assets/image/roast_code.png';
        }

        // 动态加载角色复选框
        function loadRoles(roles, containerId) {
            dbg('loadRoles:start', containerId, 'roles.len=', roles && roles.length);
            const roleColumns = document.getElementById(containerId);
            roleColumns.innerHTML = ''; // 清空容器

            // 创建两列
            const column1 = document.createElement('div');
            column1.className = 'role-column';
            const column2 = document.createElement('div');
            column2.className = 'role-column';

            // 计算分割点
            const splitIndex = Math.ceil(roles.length / 2);

            // 第一列
            for (let i = 0; i < splitIndex; i++) {
                const role = roles[i];
                const div = document.createElement('div');
                div.className = 'role-item';
                div.dataset.scripts = role.scripts ? role.scripts.join(',') : '';
                div.innerHTML = `
                    <img class="role-item-img" src="${resolveRoleImage(role)}" alt="${role.name}">
                    <label>
                        <input type="checkbox" value="${role.id}" onchange="updateSelectionCount()"> ${role.name}
                    </label>
                `;
                // 悬浮显示角色技能描述
                if (role.ability) {
                    div.title = role.ability;
                }
                column1.appendChild(div);
            }

            // 第二列
            for (let i = splitIndex; i < roles.length; i++) {
                const role = roles[i];
                const div = document.createElement('div');
                div.className = 'role-item';
                div.dataset.scripts = role.scripts ? role.scripts.join(',') : '';
                div.innerHTML = `
                    <img class="role-item-img" src="${resolveRoleImage(role)}" alt="${role.name}">
                    <label>
                        <input type="checkbox" value="${role.id}" onchange="updateSelectionCount()"> ${role.name}
                    </label>
                `;
                // 悬浮显示角色技能描述
                if (role.ability) {
                    div.title = role.ability;
                }
                column2.appendChild(div);
            }

            roleColumns.appendChild(column1);
            roleColumns.appendChild(column2);

            // 初始更新角色可见性
            updateRoleVisibility();
            dbg('loadRoles:rendered', containerId, 'children=', roleColumns.children.length);
        }


        // 更新角色可见性
        function updateRoleVisibility() {
            const selectedScripts = Array.from(document.querySelectorAll('.script-selection input[type="checkbox"]:checked'))
                .map(cb => cb.value);
            dbg('updateRoleVisibility:selectedScripts', selectedScripts);

            // 更新所有角色项的可见性
            let shown = 0, hidden = 0;
            document.querySelectorAll('.role-item').forEach(item => {
                const roleScripts = item.dataset.scripts ? item.dataset.scripts.split(',') : [];
                const showAll = selectedScripts.length === 0 || selectedScripts.includes('旧版角色');
                const shouldShow = showAll || roleScripts.length === 0 || roleScripts.some(script => selectedScripts.includes(script));
                
                if (shouldShow) {
                    item.classList.remove('hidden');
                    shown++;
                } else {
                    item.classList.add('hidden');
                    hidden++;
                }
            });
            dbg('updateRoleVisibility:done', {shown, hidden, total: shown+hidden});

            updateSelectionCount();
        }

        // 确保展开时有数据（若因任何原因未渲染，则补渲染）
        function ensureRoleColumns() {
            const ensure = (containerId, roles) => {
                const container = document.getElementById(containerId);
                if (!container) { try { console.log('[JSON生成] ensureRoleColumns:container-missing', containerId); } catch(e) {} return; }
                if (container.children.length === 0 || container.innerHTML.trim() === '') {
                    try { console.log('[JSON生成] ensureRoleColumns:re-render', containerId); } catch(e) {}
                    loadRoles(roles, containerId);
                }
            };
            ensure('townsfolk-columns', townsfolkRoles);
            ensure('outsiders-columns', outsidersRoles);
            ensure('minions-columns', minionsRoles);
            ensure('demons-columns', demonsRoles);
            ensure('travelers-columns', travelersRoles);
            ensure('fabled-columns', fabledRoles);
        }
        
        function addDirRole() {
            // 获取输入值
            const roleName = document.getElementById('dir-role-name').value.trim();
            const ability = document.getElementById('ability').value.trim();
            const schTeam = document.getElementById('sch_team').value;
            const setupCheckbox = document.querySelector('input[name="setup"]');
            const setupValue = setupCheckbox.checked ? 1 : 0;            //const setupValue = document.querySelector('input[name="setup"]:checked')?.value === "true" ? 1 : 0;
            // 根据 sch_team 确定 team 的值
            let team;
            switch (schTeam) {
                case '镇民':
                    team = 'townsfolk';
                    break;
                case '外来者':
                    team = 'outsider';
                    break;
                case '爪牙':
                    team = 'minion';
                    break;
                case '恶魔':
                    team = 'demon';
                    break;
                default:
                    team = 'traveller';
            }
            // 校验必填字段
            if (!roleName || !ability) {
                alert('角色中文名和角色能力描述为必填项，请填写完整！');
                return;
            }

            // 生成角色 id
            const id = `diyRole${dirRolesJson.length + 1}`;

    // 获取图片地址
    let imageURL = document.getElementById('image').value.trim();
    // 如果图片地址为空，根据 schTeam 赋值
    if (!imageURL) {
        switch (schTeam) {
            case '镇民':
                imageURL = 'https://clocktower-wiki.gstonegames.com/images/thumb/a/a7/Townsfolk.png/180px-Townsfolk.png';
                break;
            case '外来者':
                imageURL = 'https://clocktower-wiki.gstonegames.com/images/thumb/b/bc/Outsiders.png/180px-Outsiders.png'; 
                break;
            case '爪牙':
                imageURL = 'https://clocktower-wiki.gstonegames.com/images/thumb/4/4d/Minions.png/180px-Minions.png';
                break;
            case '恶魔':
                imageURL = 'https://clocktower-wiki.gstonegames.com/images/thumb/8/8d/Demons.png/180px-Demons.png'; 
                break;
            default:
                imageURL = 'https://clocktower-wiki.gstonegames.com/images/thumb/7/7d/Travellers_new.png/180px-Travellers_new.png'; 
        }
    }

            // 收集所有字段值
            const roleData = {
                id: id,
                name: roleName,
                ability: ability,
                team: team,
                sch_team: schTeam,
                edition: 'custom',
                firstNight: document.getElementById('firstNight').value.trim(),
                otherNight: document.getElementById('otherNight').value.trim(),
                firstNightReminder: document.getElementById('firstNightReminder').value.trim(),
                otherNightReminder: document.getElementById('otherNightReminder').value.trim(),
                reminders: [
                    document.getElementById('reminders1').value.trim(),
                    document.getElementById('reminders2').value.trim(),
                    document.getElementById('reminders3').value.trim()
                ].filter(Boolean),
                remindersGlobal: [
                    document.getElementById('remindersGlobal1').value.trim(),
                    document.getElementById('remindersGlobal2').value.trim(),
                    document.getElementById('remindersGlobal3').value.trim()
                ].filter(Boolean),
                setup: setupValue,
                image: imageURL
            };

            // 将角色数据添加到 dirRolesJson 队列
            dirRolesJson.push(roleData);

            // 清空输入框
            document.getElementById('dir-role-name').value = '';
            document.getElementById('ability').value = '';
            document.getElementById('firstNight').value = '';
            document.getElementById('otherNight').value = '';
            document.getElementById('firstNightReminder').value = '';
            document.getElementById('otherNightReminder').value = '';
            document.getElementById('reminders1').value = '';
            document.getElementById('reminders2').value = '';
            document.getElementById('reminders3').value = '';
            document.getElementById('remindersGlobal1').value = '';
            document.getElementById('remindersGlobal2').value = '';
            document.getElementById('remindersGlobal3').value = '';
            document.getElementById('image').value = '';
            setupCheckbox.checked = false;

            // 隐藏输入区域
            toggleDirInput();
            updateSelectionCount();
            //alert('自定义角色保存成功！');
        }






        // 
        function toggleDirInput() {
        const dirInputGroup = document.getElementById('dir-input-group');
        dirInputGroup.style.display = dirInputGroup.style.display === 'none' ? 'block' : 'none';
        }
        
        // 更新选择数量
        function updateSelectionCount() {
            
            let townsfolkCount = document.querySelectorAll('#townsfolk-list input[type="checkbox"]:checked:not(.hidden)').length;
            let outsidersCount = document.querySelectorAll('#outsiders-list input[type="checkbox"]:checked:not(.hidden)').length;
            let minionsCount = document.querySelectorAll('#minions-list input[type="checkbox"]:checked:not(.hidden)').length;
            let demonsCount = document.querySelectorAll('#demons-list input[type="checkbox"]:checked:not(.hidden)').length;

            // 统计自定义角色数量并加到对应类型计数中
            dirRolesJson.forEach(role => {
                switch (role.team) {
                    case 'townsfolk':
                        townsfolkCount++;
                        break;
                    case 'outsider':
                        outsidersCount++;
                        break;
                    case 'minion':
                        minionsCount++;
                        break;
                    case 'demon':
                        demonsCount++;
                        break;
                }
            });


            // 统计旧版角色数量
            let legacyCount = 0;
            document.querySelectorAll('.role-item input[type="checkbox"]:checked:not(.hidden)').forEach(checkbox => {
                const roleId = checkbox.value;
                if (legacyRolesJson.some(role => role.id === roleId)) {
                    legacyCount++;
                }
            });

            const selectionInfo = document.getElementById('selection-info');
            
            // 提取 dirRolesJson 中的 name 字段
            const customRoleNames = dirRolesJson.map(role => role.name).join('、');
            // 根据 dirRolesJson 长度决定显示内容
            let customRoleText = dirRolesJson.length > 0 ? `，分别为：${customRoleNames}` : '';
            selectionInfo.innerHTML = `已选择：镇民 ${townsfolkCount} 个，外来者 ${outsidersCount} 个，爪牙 ${minionsCount} 个，恶魔 ${demonsCount} 个。<br>(注意：其中包含旧版角色 ${legacyCount} 个)<br>(注意：其中包含自定义角色 ${dirRolesJson.length} 个${customRoleText})`;

            // 渲染预览
            renderSelectedPreview();
        }

        function resolvePreviewImage(role) {
            if (role.image) return role.image;
            if (role.id) return `https://clocktower-wiki.gstonegames.com/images/thumb/0/0a/${role.id}.png/180px-${role.id}.png`;
            return 'https://clocktower-wiki.gstonegames.com/skins/pivot/assets/image/roast_code.png';
        }

        // 简易日志工具
        function dbg(){
            try{
                const args = Array.from(arguments);
                console.log('[JSON生成]', ...args);
            }catch(e){}
        }

        function renderSelectedPreview() {
            const container = document.getElementById('selected-preview-content');
            if (!container) return;

            container.innerHTML = '';

            const getTeamZhFor = (roleObj) => {
                if (roleObj.sch_team) return roleObj.sch_team;
                if (roleObj.id) {
                    if (townsfolkRoles.some(r => r.id === roleObj.id)) return '镇民';
                    if (outsidersRoles.some(r => r.id === roleObj.id)) return '外来者';
                    if (minionsRoles.some(r => r.id === roleObj.id)) return '爪牙';
                    if (demonsRoles.some(r => r.id === roleObj.id)) return '恶魔';
                    if (travelersRoles.some(r => r.id === roleObj.id)) return '旅行者';
                    if (fabledRoles.some(r => r.id === roleObj.id)) return '传奇';
                }
                return '其他';
            };

            const groups = {
                '镇民': [],
                '外来者': [],
                '爪牙': [],
                '恶魔': [],
                '旅行者': [],
                '传奇': [],
                '其他': []
            };

            const collectCardData = (roleObj, from) => ({
                ...roleObj,
                sch_team: getTeamZhFor(roleObj),
                _from: from
            });

            // 选中的基础角色（含旅行者/传奇）
            document.querySelectorAll('.role-item input[type="checkbox"]:checked').forEach(cb => {
                const roleId = cb.value;
                const base = [...townsfolkRoles, ...outsidersRoles, ...minionsRoles, ...demonsRoles, ...travelersRoles, ...fabledRoles].find(r => r.id === roleId);
                if (base) {
                    const item = collectCardData({ id: roleId, ...base }, 'base');
                    groups[item.sch_team] = groups[item.sch_team] || [];
                    groups[item.sch_team].push(item);
                }
            });

            // 自定义角色
            dirRolesJson.forEach(role => {
                const item = collectCardData(role, 'dir');
                groups[item.sch_team] = groups[item.sch_team] || [];
                groups[item.sch_team].push(item);
            });

            const pushCard = (parent, roleObj) => {
                const card = document.createElement('div');
                card.className = 'role-item';
                card.style.display = 'flex';
                card.style.alignItems = 'center';
                card.style.justifyContent = 'space-between';
                card.style.minWidth = '260px';
                card.style.flex = '0 0 auto';
                card.style.gap = '10px';

                const left = document.createElement('div');
                left.style.display = 'flex';
                left.style.alignItems = 'center';
                left.style.gap = '10px';

                const img = document.createElement('img');
                img.className = 'role-item-img';
                img.src = resolvePreviewImage(roleObj);
                img.alt = roleObj.name || roleObj.id;

                const label = document.createElement('label');
                label.textContent = `${roleObj.name || roleObj.id}`;
                label.style.fontWeight = '600';

                const sub = document.createElement('div');
                sub.style.fontSize = '12px';
                sub.style.color = '#666';
                sub.textContent = roleObj.sch_team || '';

                const info = document.createElement('div');
                info.appendChild(label);
                info.appendChild(sub);

                left.appendChild(img);
                left.appendChild(info);

                const removeBtn = document.createElement('button');
                removeBtn.className = 'violet-button';
                removeBtn.textContent = '移除';
                removeBtn.onclick = () => {
                    if (roleObj._from === 'dir') {
                        dirRolesJson = dirRolesJson.filter(r => r !== roleObj);
                    } else if (roleObj.id) {
                        const cb = document.querySelector(`.role-item input[type=\"checkbox\"][value=\"${roleObj.id}\"]`);
                        if (cb) cb.checked = false;
                    }
                    updateSelectionCount();
                };

                // 预览卡片悬浮也显示技能
                if (roleObj.ability) card.title = roleObj.ability;

                card.appendChild(left);
                card.appendChild(removeBtn);
                parent.appendChild(card);
            };

            const order = ['镇民','外来者','爪牙','恶魔','旅行者','传奇','其他'];
            order.forEach(name => {
                const list = groups[name] || [];
                if (list.length === 0) return;

                const columnWrap = document.createElement('div');
                columnWrap.style.display = 'flex';
                columnWrap.style.flexDirection = 'column';
                columnWrap.style.gap = '8px';

                const title = document.createElement('div');
                title.style.fontWeight = '700';
                title.textContent = `${name}（${list.length}）`;
                columnWrap.appendChild(title);

                const row = document.createElement('div');
                row.style.display = 'flex';
                row.style.flexWrap = 'wrap';
                row.style.gap = '8px';
                columnWrap.appendChild(row);

                container.appendChild(columnWrap);

                list.forEach(r => pushCard(row, r));
            });
        }
        // 生成JSON文件
        function generateJson() {
            const selectedRoles = getSelectedRoles();
            if (selectedRoles.length === 0 && dirRolesJson.length === 0)  {
                alert("请至少选择一个角色！");
                return;
            }

            // 收集元信息
            const metaName = document.getElementById('meta-name').value.trim();
            if (!metaName) {
                alert('请填写剧本名称');
                return;
            }
            const metaAuthor = document.getElementById('meta-author').value.trim();
            const metaLogo = document.getElementById('meta-logo').value.trim();
            const metaDescription = document.getElementById('meta-description').value.trim();
            const metaVersion = document.getElementById('meta-version').value.trim();
            const townsfolkName = document.getElementById('meta-townsfolkName').value.trim() || '镇民';
            const outsidersName = document.getElementById('meta-outsidersName').value.trim() || '外来者';
            const minionsName = document.getElementById('meta-minionsName').value.trim() || '爪牙';
            const demonsName = document.getElementById('meta-demonsName').value.trim() || '恶魔';

            const meta = {
                id: '_meta',
                name: metaName,
                author: metaAuthor,
                logo: metaLogo,
                description: metaDescription,
                version: metaVersion,
                townsfolkName,
                outsidersName,
                minionsName,
                demonsName,
                townsfolk: townsfolkName,
                outsider: outsidersName,
                minion: minionsName,
                demon: demonsName
            };

            // 处理选中的角色：legacy 用库中完整对象；其余保留 getSelectedRoles 生成的完整对象
            const processedRoles = selectedRoles.map(role => {
                const legacyRole = legacyRolesJson.find(r => r.id === role.id);
                if (legacyRole) return legacyRole;
                return role;
            });
            // 将 dirRolesJson 中的内容添加到处理后的角色列表中
            const allRoles = [meta, ...processedRoles, ...dirRolesJson];

            const jsonData = JSON.stringify(allRoles, null, 4);
            const blob = new Blob([jsonData], { type: 'application/json' });
            const url = URL.createObjectURL(blob);

            const a = document.createElement('a');
            a.href = url;
            a.download = (document.getElementById('meta-name').value.trim() || '工具生成的血染钟楼剧本JSON') + '.json';
            a.click();
            URL.revokeObjectURL(url);

            alert("JSON文件已生成！");
        }

        // 获取选中的完整角色数据
        function getSelectedRoles() {
            const selectedRoles = [];
            const checkedIds = new Set();

            document.querySelectorAll('.role-item input:checked').forEach(checkbox => {
                const roleId = checkbox.value;
                
                // 检查是否为旧版角色
                const legacyRole = legacyRolesJson.find(r => r.id === roleId);
                if (legacyRole) {
                    if (!checkedIds.has(roleId)) {
                        selectedRoles.push(legacyRole);
                        checkedIds.add(roleId);
                    }
                    return;
                }

                // 处理非旧版角色
                const baseRole = [...townsfolkRoles, ...outsidersRoles, ...minionsRoles, ...demonsRoles, ...travelersRoles, ...fabledRoles]
                    .find(r => r.id === roleId);
                
                if (baseRole && !checkedIds.has(roleId)) {
                    const teamZh = getRoleTeam(roleId);
                    const teamEn = getRoleTeamEn(roleId);
                    selectedRoles.push(Object.assign({
                        id: roleId,
                        edition: 'custom',
                        name: baseRole.name,
                        ability: baseRole.ability || '',
                        team: teamEn,
                        sch_team: teamZh,
                        firstNight: baseRole.firstNight || 0,
                        otherNight: baseRole.otherNight || 0,
                        firstNightReminder: baseRole.firstNightReminder || '',
                        otherNightReminder: baseRole.otherNightReminder || '',
                        reminders: baseRole.reminders || [],
                        remindersGlobal: baseRole.remindersGlobal || [],
                        setup: baseRole.setup || 0,
                        image: baseRole.image || `https://clocktower-wiki.gstonegames.com/images/thumb/0/0a/${roleId}.png/300px-${roleId}.png`
                    }, {}));
                    checkedIds.add(roleId);
                }
            });

            return selectedRoles;
        }

        // 随机工具：清空、随机勾选
        function clearAllSelections() {
            document.querySelectorAll('.role-item input[type="checkbox"]').forEach(cb => cb.checked = false);
            dirRolesJson = [];
            updateSelectionCount();
        }

        function randomSelectRoles() {
            // 读取目标数量
            const needTown = Math.max(0, parseInt(document.getElementById('rand-townsfolk').value || '0'));
            const needOuts = Math.max(0, parseInt(document.getElementById('rand-outsiders').value || '0'));
            const needMini = Math.max(0, parseInt(document.getElementById('rand-minions').value || '0'));
            const needDemo = Math.max(0, parseInt(document.getElementById('rand-demons').value || '0'));
            const needTrav = Math.max(0, parseInt(document.getElementById('rand-travelers').value || '0'));
            const needFabl = Math.max(0, parseInt(document.getElementById('rand-fabled').value || '0'));

            // 清空勾选
            document.querySelectorAll('.role-item input[type="checkbox"]').forEach(cb => cb.checked = false);

            // 基于 DOM 可见项收集候选（遵循脚本过滤与折叠）
            const toIds = (selector) => Array.from(document.querySelectorAll(`${selector} .role-item:not(.hidden) input[type="checkbox"]`)).map(x => x.value);
            const townIds = toIds('#townsfolk-list');
            const outsIds = toIds('#outsiders-list');
            const miniIds = toIds('#minions-list');
            const demoIds = toIds('#demons-list');
            const travIds = toIds('#travelers-list');
            const fablIds = toIds('#fabled-list');

            const shuffle = (arr) => {
                for (let i = arr.length - 1; i > 0; i--) {
                    const j = Math.floor(Math.random() * (i + 1));
                    [arr[i], arr[j]] = [arr[j], arr[i]];
                }
                return arr;
            };

            const pickN = (ids, n) => shuffle(ids.slice()).slice(0, Math.min(n, ids.length));

            const chosen = [
                ...pickN(townIds, needTown),
                ...pickN(outsIds, needOuts),
                ...pickN(miniIds, needMini),
                ...pickN(demoIds, needDemo),
                ...pickN(travIds, needTrav),
                ...pickN(fablIds, needFabl)
            ];

            chosen.forEach(id => {
                const cb = document.querySelector(`.role-item input[type="checkbox"][value="${id}"]`);
                if (cb) {
                    cb.checked = true;
                    try {
                        cb.dispatchEvent(new Event('input', { bubbles: true }));
                        cb.dispatchEvent(new Event('change', { bubbles: true }));
                    } catch(e) {}
                    // 确保所在分组展开可见
                    const details = cb.closest('details');
                    if (details) details.open = true;
                    // 为选中项添加轻微高亮提示（1.5s）
                    const item = cb.closest('.role-item');
                    if (item) {
                        const oldBg = item.style.backgroundColor;
                        item.style.backgroundColor = 'rgba(102,126,234,0.12)';
                        setTimeout(() => { item.style.backgroundColor = oldBg || ''; }, 1500);
                    }
                }
            });

            updateSelectionCount();
        }



        // 获取角色类型
        function getRoleTeam(roleId) {
            if (townsfolkRoles.some(r => r.id === roleId)) return '镇民';
            if (outsidersRoles.some(r => r.id === roleId)) return '外来者';
            if (minionsRoles.some(r => r.id === roleId)) return '爪牙';
            if (demonsRoles.some(r => r.id === roleId)) return '恶魔';
            if (travelersRoles.some(r => r.id === roleId)) return '旅行者';
            if (fabledRoles.some(r => r.id === roleId)) return '传奇';
            return '未知';
        }

        function getRoleTeamEn(roleId) {
            if (townsfolkRoles.some(r => r.id === roleId)) return 'townsfolk';
            if (outsidersRoles.some(r => r.id === roleId)) return 'outsider';
            if (minionsRoles.some(r => r.id === roleId)) return 'minion';
            if (demonsRoles.some(r => r.id === roleId)) return 'demon';
            if (travelersRoles.some(r => r.id === roleId)) return 'traveler';
            if (fabledRoles.some(r => r.id === roleId)) return 'fabled';
            return 'traveler';
        }

        // 初始化加载角色（DOMContentLoaded 更早渲染，避免资源阻塞导致"看起来消失"）
        document.addEventListener('DOMContentLoaded', function() {
            loadRoles(townsfolkRoles, 'townsfolk-columns');
            loadRoles(outsidersRoles, 'outsiders-columns');
            loadRoles(minionsRoles, 'minions-columns');
            loadRoles(demonsRoles, 'demons-columns');
            loadRoles(travelersRoles, 'travelers-columns');
            loadRoles(fabledRoles, 'fabled-columns');

            document.querySelectorAll('.script-selection input[type="checkbox"]').forEach(checkbox => {
                checkbox.addEventListener('change', updateRoleVisibility);
            });

            // 初始可见性&预览：若无任何脚本被勾选，默认全选
            const anyChecked = document.querySelector('.script-selection input[type="checkbox"]:checked');
            if (!anyChecked) {
                document.querySelectorAll('.script-selection input[type="checkbox"]').forEach(cb => cb.checked = true);
            }
            updateRoleVisibility();

            // 为四个 details 绑定展开时的补渲染
            ['townsfolk-list','outsiders-list','minions-list','demons-list','travelers-list','fabled-list'].forEach(id => {
                const det = document.getElementById(id);
                if (det) det.addEventListener('toggle', ensureRoleColumns);
            });
        });



    </script>
</body>
</html>

